Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {"books":[
- {
- "title": "The Adventures in JSON",
- ...
- "publisher": "New York Publisher Ltd",
- "author": {
- "name": "Freddie Jsonwood",
- "nationality": "Some Nationality",
- ...
- }
- },{
- "title": "Psychology Treatment Of Confused Developers After JSON Exposure",
- ...
- "publisher": "San Francisco Publisher Ltd",
- "author": {
- "name": "Abraham Jsonwall",
- "nationality": "Some Nationality",
- ...
- }
- },...
- ]
- }
- JsonArray items = (JsonArray)rootitems["rootitems"];
- var query = (from item in items select new Book
- {
- Title = item["title"],
- Publisher = item["publisher"],
- ...
- BookUrl = item["bookurl"],
- // The above code is easy and works
- // Now I don't know how to do it
- // I can have ONLY one author,
- // so I'd like to do something like this
- AuthorName = item["author"]["name"],
- AuthorNationality = item["author"]["nationality"],
- ...
- }
- Book
- public string Title
- public string Publisher
- public string AuthorName
- public string AuthorNationality
- var query = (from item in items select new Book
- {
- Title = item["title"],
- Publisher = item["publisher"],
- ...
- BookUrl = item["bookurl"],
- // Now I don't know how to do it
- // Author is a class and, in my case,
- // I can have ONLY one author,
- // so I'd like to do something like this
- Author = (from a item["author"] select new Author
- {
- AuthorName = a["name"],
- AuthorNationality = a["nationality"],
- ...
- }
- ...
- }
- Book
- public string Title
- public string Publisher
- public Author Author
- Author
- public string Name
- public string Nationality
Add Comment
Please, Sign In to add comment