- JSON.simple Tutorial
- JSON.simple - Home
- JSON.simple - Overview
- JSON.simple - Environment Setup
- JSON.simple - JAVA Mapping
- Decoding Examples
- Escaping Special Characters
- JSON.simple - Using JSONValue
- JSON.simple - Exception Handling
- JSON.simple - Container Factory
- JSON.simple - Content Handler
- Encoding Examples
- JSON.simple - Encode JSONObject
- JSON.simple - Encode JSONArray
- Merging Examples
- JSON.simple - Merging Objects
- JSON.simple - Merging Arrays
- Combination Examples
- JSON.simple - Primitive, Object, Array
- JSON.simple - Primitive, Map, List
- Primitive, Object, Map, List
- Customization Examples
- JSON.simple - Customized Output
- Customized Output Streaming
- JSON.simple Useful Resources
- JSON.simple - Quick Guide
- JSON.simple - Useful Resources
- JSON.simple - Discussion
JSON.simple - Merging Arrays
In JSON.simple, we can merge two JSON Arrays easily using JSONArray.addAll() method.
Following example illustrates the above concept.
Example
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); } }
Output
["foo",100,1000.21,true,null]
Advertisements
To Continue Learning Please Login
Login with Google