I'm using Windows Phone 8.1 SDK. I'm trying to convert a JSON string into a dynamic object. This is different from most cases because, just like with the Facebook APIs, there's no predefined class to associate the string with. Specifically, I have a json string like:
{
"indexes": {
"000000": "3d6d0abf0ae645eaf8bf090a2685c29a",
"000001": "3d6d0abf0ae645eaf8bf090a2685c29a"
}
}
and so on. This means I can't obviously associate a class to the object, because property names are dynamic. What I want is being able to iterate through the values, keeping in mind that the hierarchy is "indexes"->"000000"->Value , "indexes"->"000001"->Value , "indexes"->"..."->Value . I've looked into JSON.NET , trying to deserialize into an ExpandoObject, but that doesn't work because it looks like the ExpandoObjectConverter gives a bunch of compilation errors, maybe because of the Windows Phone 8.1 environment? Anyway, I've kinda hit a wall, so any suggestions would be welcome.
EDIT: My example was poorly chosen, what I need is a more general-purpose conversion, because it could be a recursive structure, where one or more fields may be missing, e.g.:
{
"friends": {
"020709": {
"JohnSmith" : {
"email": "johnsmith@something",
"mobile": "110011001100"
}
},
"010305": {
"PaulRoss" : {
"address": "Some way or the other",
"email": "paulross@something",
}
}
}}
This is quite easy to do in Perl because of generic hash maps, but it looks like there is no real equivalent in C#?