Json Object to a Multidimensional C# Array?

Posted by Nick Brooks on Stack Overflow See other posts from Stack Overflow or by Nick Brooks
Published on 2010-04-08T18:17:33Z Indexed on 2010/04/08 19:13 UTC
Read the original article Hit count: 203

Filed under:
|
|

Is there a way to convert a Json Object to a Multidimensional C# Array? I know it might be impractical but I can't be bothered to write classes and then deserialize the strings into them.

List<string> ohyeah = (List<string>)JsonConvert.DeserializeObject(g.CommToken);

That returns an Invalid Cast exception!

Example:

{"method":"getCommunicationToken","header":{"uuid":"9B39AAB0-49A6-AC7A-BA74-DE9DA66C62B7","clientRevision":"20100323.02","session":"c0d3e8b5d661f74c68ad72af17aeb5a1","client":"gslite"},"parameters":{"secretKey":"d9b687fa10c927f102cde9c085f9377f"}}

I need to get something like that :

j["method"]; //This will equal to getCommunicationToken
j["header"]["uuid"]; //This will equal to 9B39AAB0-49A6-AC7A-BA74-DE9DA66C62B7

I literally need to parse the json object into an array.

© Stack Overflow or respective owner

Related posts about c#

Related posts about JSON