我已经在这些方面看到了相当多的问题并尝试了许多建议的解决方案,但似乎无法解决这个问题。我正在尝试将JSON转换为c#中的对象。有问题的JSON有一个不寻常的(对我来说)布局,包含一个嵌套的JSON和一个单独的数组。任何建议将不胜感激。我已经粘贴了两张JSON记录。我的努力包括创建一个与JSON布局匹配的类,并尝试反序列化到这个类中。我可以提供有用的代码。
JSON:
[ [ { "eid" : "113580662029802",
"eids" : [ 113580662029802 ],
"event_date" : "Thursday, April 28th, 2011",
"event_id" : "2476353",
"event_notes" : "",
"event_time" : "8:00 pm",
"event_time_8601" : "2011-04-28T20:00:00-04:00",
"event_timestamp" : 1304035200,
"event_title" : "Colin Hay",
"facebook_event_url" : "http://www.facebook.com/event.php?eid=113580662029802",
"lat" : "42.2793",
"links" : [ { "link_title" : "8:00 pm",
"link_type" : "ticket",
"link_url" : "http://tickets.sonicliving.com/event/2476353/sl-tickets"
} ],
"lon" : "-83.7486",
"poster_url_large" : "http://posters.sonicliving.com/event/2476353/poster.png",
"poster_url_small" : "http://posters.sonicliving.com/event/2476353/smallposter.png",
"rsvp" : "1",
"venue_address" : "316 S. Main St.",
"venue_city" : "Ann Arbor",
"venue_country" : "US",
"venue_id" : "3919",
"venue_name" : "The Ark",
"venue_phone" : "(800) 745-3000",
"venue_state" : "MI"
} ],
[ { "eid" : "199014973442276",
"eids" : [ 199014973442276 ],
"event_date" : "Wednesday, April 13th, 2011",
"event_id" : "2801497",
"event_notes" : "",
"event_time" : "8:00 pm",
"event_time_8601" : "2011-04-13T20:00:00-04:00",
"event_timestamp" : 1302739200,
"event_title" : "Tobacco / Beans / SHAPERS",
"facebook_event_url" : "http://www.facebook.com/event.php?eid=199014973442276",
"lat" : "42.2804",
"links" : [ { "link_title" : "8:00 pm",
"link_type" : "details",
"link_url" : "http://sonicliving.com/event/2801497"
} ],
"lon" : "-83.7512",
"poster_url_large" : "http://posters.sonicliving.com/event/2801497/poster.png",
"poster_url_small" : "http://posters.sonicliving.com/event/2801497/smallposter.png",
"rsvp" : "6",
"venue_address" : "208 S 1st St",
"venue_city" : "Ann Arbor",
"venue_country" : "US",
"venue_id" : "29340",
"venue_name" : "Blind Pig",
"venue_phone" : "(734) 996-8555",
"venue_state" : "MI"
} ]
]
答案 0 :(得分:0)
我建议在C#(类等)中创建对象结构,然后使用JavaScriptSerializer(并可能创建自己的JavaScriptConverter)来将信息解析为这些对象。