-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:
@@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user