Question

EDITED:

If I load a google spreadsheet using JSON URL into a dynamic C# object, I can't access some entries because the JSON looks like this:

"author": [
  {
    "name": {
      "$t": "XYZ"
    },
    "email": {
      "$t": "XYZ@gmail.com"
    }
  }
]

Why does the google JSON have $ namespaces? Can we remove them? What can be done?

Here is the code:

var json = new WebClient().DownloadString(@"GoogleUrlWithJson");
dynamic jsonObj = JsonConvert.DeserializeObject(json);
string a = jsonObj.feed.entry[0].author.name.$t; ==> Can't compile error "unexpected $"
Was it helpful?

Solution

Try using square bracket syntax to access the JSON property names that have $ in them:

string a = jsonObj.feed.entry[0].author.name["$t"];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top