How to combine/merge two JArrays in JSON.NET

前端 未结 4 1086
半阙折子戏
半阙折子戏 2021-01-04 02:38

I can\'t figure out how to concatenate two JArrays that I got be using JArray.Parse? The order of the arrays must be preserved i.e. the first array should be first and eleme

4条回答
  •  心在旅途
    2021-01-04 03:05

    You can also use the union method:

    JArray test1 = JArray.Parse("[\"john\"]");
    JArray test2 = JArray.Parse("[\"doe\"]");
    test1 = new JArray(test1.Union(test2));
    

    Now test1 is

    [
      "john",
      "doe"
    ]
    

提交回复
热议问题