문제

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 $"
도움이 되었습니까?

해결책

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

string a = jsonObj.feed.entry[0].author.name["$t"];
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top