I have an IEnumerable<dynamic>
which I get from a dapper query which serialized using json.net gives as below..
[{"id": "ZoomIn", "label": "Zoom In"},
{"id": "ZoomOut", "label": "Zoom Out"},
{"id": "OriginalView", "label": "Original View"}]
I want the json in the below format..
[["ZoomIn","Zoom In"],
["ZoomOut","Zoom Out"],
["OriginalView","Original View"]]
Any help is sincerely appreciated.
Thanks
simple snippet using JavaScriptSerializer,
public class Friends
{
public List<FacebookFriend> data {get;set;}
}
public class FacebookFriend
{
public string id {get;set;}
public string label{get;set;}
}
Friends facebookFriends = new JavaScriptSerializer().Deserialize<Friends>(result);
string json=
@"{""data"":[{"id": "ZoomIn", "label": "Zoom In"},
{"id": "ZoomOut", "label": "Zoom Out"},
{"id": "OriginalView", "label": "Original View"}]}";
Friends facebookFriends = new System.Web.Script.Serialization.JavaScriptSerializer().Deserialize<Friends>(json);
foreach(var item in facebookFriends.data)
{
Console.WriteLine("id: {0}, label: {1}",item.id,item.label);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.