tl  tr
  Home | Tutorials | Articles | Videos | Products | Tools | Search
Interviews | Open Source | Tag Cloud | Follow Us | Bookmark | Contact   
 JSON > JSON SIMPLE > Merge JSON Array

Merge JSON Array 

JSON Simple is a java library for encoding and decoding JSON text. Get the latest binaries from http://code.google.com/p/json-simple/. The following example shows merging two JSON Arrays.

File Name  :  
com/bethecoder/tutorials/json_simple/tests/MergeJsonArrays.java 
Author  :  Sudhakar KV
Email  :  [email protected]
   
package com.bethecoder.tutorials.json_simple.tests;

import java.io.IOException;

import org.json.simple.JSONArray;

public class MergeJsonArrays {

  /**
   @param args
   @throws IOException 
   */
  public static void main(String[] argsthrows IOException {

    JSONArray jsonArray = new JSONArray();
    jsonArray.add("one");
    jsonArray.add("two");
    jsonArray.add("three");
    
    JSONArray jsonArray2 = new JSONArray();
    jsonArray2.add("three");
    jsonArray2.add("four");

    jsonArray.addAll(jsonArray2);
    System.out.println(jsonArray);
  }

}
   

It gives the following output,
["one","two","three","three","four"]



 
  


  
bl  br