[英]How do I merge multiple json objects
I use different urls get similar json data. 我使用不同的网址获得相似的json数据。
So that I can get more information in the same model 这样我就可以在同一模型中获得更多信息
It has trouble me for a long time 困扰了我好久
i tried to use json.net for a single list. 我试图将json.net用于单个列表。
string url1= "https://apt.data2.com";
string url2= "https://apt.data1.com";
var json1= webClient.DownloadString(url1);
var json2= webClient.DownloadString(url2);
These calls return multiple json objects with the same structure 这些调用返回具有相同结构的多个json对象
{
data: [
{
created_time: "1457332172",
text: "什麼東西",
from: {
username: "d86241",
profile_picture: "https://scontent.cdninstagram.com/t51.2885-19/s150x150/11371189_421316874725117_327631552_a.jpg",
id: "397355082",
full_name: "Jhao-wei Hvang"
},
id: "1200511729352353899"
}
]
}
and 和
{
data: [
{
created_time: "1111",
text: "hi",
from: {
username: "22",
profile_picture: "",
id: "ss",
full_name: "Hvang"
},
id: "1200511352353899"
}
]
}
I want to combine these objects to produce 我想结合这些对象来产生
{
data:[
{
created_time:"1234"
text:...
....
......
},
id:1234....
]
data:[
{
created_time:"4567"
text:....
....
......
},
id:4567....
]
}
How do I merge these into a single json object? 如何将它们合并到单个json对象中?
@foreach (var item in Model)
{
@ Item.text
}
var jObject1 = // Your first json object as JObject
var jObject2 = // Your second json object as JObject
jObject1.Merge(jObject2);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.