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?

3
  • 1
    Related: JSON.NET JObject key comparison case-insensitive Commented Nov 16, 2018 at 6:51
  • @BrianRogers - the fix given there is inline. I wante to fix this globally, like using JsonSerializerSettings, etc Commented Nov 16, 2018 at 6:57
  • 1
    Yep, I know; that is why I did not mark this question as a duplicate. Commented Nov 16, 2018 at 7:03

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.