-Fixed error when deserializing nullable structs

-Fixed writing JSON Schema option label
-Improved error message when converting JSON with an empty property to XML
This commit is contained in:
JamesNK
2010-10-22 23:23:49 +00:00
parent 1703992773
commit 15ea91fb63
8 changed files with 283 additions and 58 deletions
@@ -512,15 +512,15 @@ namespace Newtonsoft.Json.Tests.Schema
""options"": [
{
""value"": 0,
""value"": ""No""
""label"": ""No""
},
{
""value"": 1,
""value"": ""Asc""
""label"": ""Asc""
},
{
""value"": -1,
""value"": ""Desc""
""label"": ""Desc""
}
]
}
@@ -340,5 +340,42 @@ namespace Newtonsoft.Json.Tests.Schema
]
}", json);
}
[Test]
public void ReadOptions()
{
JsonSchema schema = JsonSchema.Parse(@"{
""type"": ""object"",
""properties"": {
""x"": {
""type"": ""integer"",
""enum"": [
0,
1,
-1
],
""options"": [
{
""value"": 0,
""label"": ""No""
},
{
""value"": 1,
""label"": ""Asc""
},
{
""value"": -1,
""label"": ""Desc""
}
]
}
}
}");
Assert.AreEqual(schema.Properties["x"].Options.Count, 3);
Assert.AreEqual(schema.Properties["x"].Options[0], "No");
Assert.AreEqual(schema.Properties["x"].Options[1], "Asc");
Assert.AreEqual(schema.Properties["x"].Options[-1], "Desc");
}
}
}