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

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

+4
source share
1 answer
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) }); 
+9
source

Source: https://habr.com/ru/post/1440026/


All Articles