如何在JSON.NET中合并/合并两个JArray

编程入门 行业动态 更新时间:2024-10-27 22:30:07
本文介绍了如何在JSON.NET中合并/合并两个JArray的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我不知道如何连接使用JArray.Parse的两个JArray?数组的顺序必须保留,即第一个数组应该是第一个,然后是几秒钟的元素.

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 element in seconds should come afterwards.

推荐答案

您可以通过调用JArray.Add(element)将元素添加到一个JArray中,其中元素来自第二个JArray.您需要遍历第二个JArray以添加所有这些元素,但这将完成您想要的:

You can add elements to one JArray by calling JArray.Add(element) where element comes from the second JArray. You'll need to loop over the second JArray to add all of these elements, but this will accomplish what you want:

for(int i=0; i<jarrayTwo.Count; i++) { jarrayOne.Add(jarrayTwo[i]); }

在上面的示例中,

现在将依次包含第一个数组的所有元素,然后是第二个数组的元素.您可以浏览 JArray文档以获得更多详细信息.

in the above example jarrayOne will now contain all of the first array's elements followed by the second array's elements in sequence. You can take a look through the JArray documentation for further details.

更多推荐

如何在JSON.NET中合并/合并两个JArray

本文发布于:2023-10-24 23:52:55,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1525351.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:两个   如何在   NET   JSON   JArray

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!