Skip to content

Instantly share code, notes, and snippets.

@sinergy
Created May 22, 2013 10:45
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save sinergy/5626704 to your computer and use it in GitHub Desktop.
Save sinergy/5626704 to your computer and use it in GitHub Desktop.
Check if Key existed in the JsonData Object of LitJSON (A C# JSON Parser) source: http://goo.gl/NxBcP
static public bool JsonDataContainsKey(JsonData data,string key)
{
bool result = false;
if(data == null)
return result;
if(!data.IsObject)
{
return result;
}
IDictionary tdictionary = data as IDictionary;
if(tdictionary == null)
return result;
if(tdictionary.Contains(key))
{
result = true;
}
return result;
}
@AnthonyUccello
Copy link

Just what I needed. Thank you!

I can verify this works!

@goreacraft
Copy link

thank you

@Benraay
Copy link

Benraay commented Feb 4, 2016

a much simpler way :
data.Keys.Contains(key)

@mghamsar
Copy link

mghamsar commented Aug 3, 2016

<3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment