-Fixed generating generic simple type names

-Changed JsonObjectAttribute to be compatible with structs
This commit is contained in:
JamesNK
2010-07-06 10:20:10 +00:00
parent c2800930ab
commit 08b8477f5e
9 changed files with 117 additions and 4 deletions
@@ -3506,5 +3506,32 @@ keyword such as type of business.""
JsonConvert.DeserializeObject<StringDictionaryTestClass>(json);
}
#endif
[JsonObject(MemberSerialization.OptIn)]
public struct StructWithAttribute
{
public string MyString { get; set; }
[JsonProperty]
public int MyInt { get; set; }
}
[Test]
public void SerializeStructWithJsonObjectAttribute()
{
StructWithAttribute testStruct = new StructWithAttribute
{
MyInt = int.MaxValue
};
string json = JsonConvert.SerializeObject(testStruct, Formatting.Indented);
Assert.AreEqual(@"{
""MyInt"": 2147483647
}", json);
StructWithAttribute newStruct = JsonConvert.DeserializeObject<StructWithAttribute>(json);
Assert.AreEqual(int.MaxValue, newStruct.MyInt);
}
}
}