JSON.simple Tutorial
Selected Reading
- JSON.simple - Discussion
- JSON.simple - Useful Resources
- JSON.simple - Quick Guide
- Customized Output Streaming
- JSON.simple - Customized Output
- Primitive, Object, Map, List
- JSON.simple - Primitive, Map, List
- JSON.simple - Primitive, Object, Array
- JSON.simple - Merging Arrays
- JSON.simple - Merging Objects
- JSON.simple - Encode JSONArray
- JSON.simple - Encode JSONObject
- JSON.simple - Content Handler
- JSON.simple - Container Factory
- JSON.simple - Exception Handling
- JSON.simple - Using JSONValue
- Escaping Special Characters
- JSON.simple - JAVA Mapping
- JSON.simple - Environment Setup
- JSON.simple - Overview
- JSON.simple - Home
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
JSON.simple - Merging Arrays
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 { pubpc static void main(String[] args) throws IOException { JSONArray pst1 = new JSONArray(); pst1.add("foo"); pst1.add(new Integer(100)); JSONArray pst2 = new JSONArray(); pst2.add(new Double(1000.21)); pst2.add(new Boolean(true)); pst2.add(null); pst1.addAll(pst2); System.out.println(pst1); } }
Output
["foo",100,1000.21,true,null]Advertisements