JSON.NET \ how to concat two JSONs in JSon.net

夙愿已清 提交于 2019-12-10 15:05:39

问题


I have two JSONs (as simple strings) - is there neat way to concat them? As part of the infrastructure??


回答1:


string j1 = @"{""a"":1}";
string j2 = @"{""b"":2}";

var j = JsonConvert.SerializeObject(new[] { JsonConvert.DeserializeObject(j1), 
                                            JsonConvert.DeserializeObject(j2) });

or

var j = JsonConvert.SerializeObject(new { obj1 = JObject.Parse(j1), 
                                          obj2 = JObject.Parse(j2) });


来源:https://stackoverflow.com/questions/12913396/json-net-how-to-concat-two-jsons-in-json-net

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!