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
  • 125,747
  • 31
  • 299
  • 300
nari447
  • 834
  • 2
  • 11
  • 25

0 Answers0