JSON.simple - 合并数组
在 JSON.simple 中,我们可以使用 JSONArray.addAll() 方法轻松合并两个 JSON 数组。
以下示例说明了上述概念。
示例
import java.io.IOException; import org.json.simple.JSONArray; class JsonDemo { public static void main(String[] args) throws IOException { JSONArray list1 = new JSONArray(); list1.add("foo"); list1.add(new Integer(100)); JSONArray list2 = new JSONArray(); list2.add(new Double(1000.21)); list2.add(new Boolean(true)); list2.add(null); list1.addAll(list2); System.out.println(list1); } }
输出
["foo",100,1000.21,true,null]