1

In my new project I see extensive usage of JToken and JObject like below, where objects are accessed by hardcoded property names.

JsonConvert.DeserializeObject<JObject>(response.Content, this.DefaultSerializerSettings)
           .Value<JToken>("result")
           .Value<JObject>("memberProduct")
           .ToObject<MemberProduct>();

The problem here is if property names in the response come with different case, the .Value<JToken>("result").Value<JObject>("memberProduct") part fails to pick out the data.

I want to make JToken and JObject work case-insensitively globally throughout the project, so that I don't have to correct the code all over the place (which I'm planning to do later).

Is there some way to do this?

Brian Rogers
  • 118,414
  • 30
  • 277
  • 278
nari447
  • 624
  • 2
  • 8
  • 23

0 Answers0