Created
May 22, 2013 10:45
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} |
a much simpler way :
data.Keys.Contains(key)
<3
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thank you