Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LINQ JObject not exporting ContainsKey #854

Closed
ambs opened this issue Mar 23, 2016 · 4 comments
Closed

LINQ JObject not exporting ContainsKey #854

ambs opened this issue Mar 23, 2016 · 4 comments

Comments

@ambs
Copy link

ambs commented Mar 23, 2016

Hi

At
https://github.com/JamesNK/Newtonsoft.Json/blob/master/Src/Newtonsoft.Json/Linq/JObject.cs#L544
ContainsKey is not public.
Where I could do

  float x = hash.ContainsKey('x') ? (float)hash['x'] : 0f;

I am needing to write

    float x;
   JToken t;
   if (hash.TryGetValue('x', out t)) {
      x= (float)t;
  } else { x = 0f; }

Or am I missing something?

Thanks

@shmuelie
Copy link

@ambs you could cast the JObject to a IDictionary<string, JToken> to get access to ContainsKey (though I agree you shouldn't have to)

@ambs
Copy link
Author

ambs commented Jul 11, 2017

Yep, can't recall how, but I solved the issue. But always good to have it explicitly.

@JamesNK
Copy link
Owner

JamesNK commented Jul 11, 2017

I meant to make it public in 10 but I forgot. It will be public in 11.

@JamesNK
Copy link
Owner

JamesNK commented Nov 26, 2017

Done a138852

@JamesNK JamesNK closed this as completed Nov 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants