JSON.NET JToken Keys Are Case Sensitive?

前端 未结 2 566
谎友^
谎友^ 2021-01-12 09:46

I\'m having to perform some custom deserialization with JSON.NET and I just found that it\'s treating the key values in a JToken as case sensitive. Here\'s some code:

<
2条回答
  •  萌比男神i
    2021-01-12 10:08

    You can cast JToken to JObject and do this:

    string ver = ((JObject)token).GetValue("version", StringComparison.OrdinalIgnoreCase)?.Value();
    

提交回复
热议问题