我有键值JToken,服务器发送给我。我如何通过json.net做同样的事情?
示例:
{
"1_type": "sound",
"1url": "http://example.com/sound.mp3",
"2_type": "url",
"2url": "http://example.com",
}
答案 0 :(得分:3)
使用Json.Net
JObject jObj = new JObject();
jObj["1_type"] = "sound";
jObj["1url"] = "http://example.com/sound.mp3";
jObj["2_type"] = "url";
jObj["2url"] = "http://example.com";
var jsonString = jObj.ToString();