Using Json.NET 10.0.3. Consider the following sample:
class Foo
{
[JsonProperty("ids")]
public int[] MyIds { get; set; }
}
Obviously, the elements of the array are unnamed. Now consider the following json
:
{
"ids": [{
"id": 1
}, {
"id": 2
}
]
}
And then we try to parse it:
var json = @"{""ids"":[{""id"":1},{""id"":2}]}";
var result = JsonConvert.DeserializeObject<Foo>(son);
Parsing the above fails with the following message:
Newtonsoft.Json.JsonReaderException: Unexpected character encountered while parsing value: {. Path 'ids', line 1, position 9.
I know I can wrap int
in a class and name it "id" there, but I'm wondering if this can be done without this extra work. The reason being what appears to be a limitation in SQL Server 2016
. See this question.