Reputation: 2784
I have two JSONs (as simple strings) - is there neat way to concat them? As part of the infrastructure??
Upvotes: 5
Views: 10477
Reputation: 116108
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) });
Upvotes: 10