4:14 am - Thursday July 19, 2018

Example program for Merging two JSONobjects

CANDID INDUSTRIAL TRAINING -- CHENNAI
Corporate Training for Experienced Candidate
Struts | Hibernate | Spring | Java / J2EE
SOAP | RestFull | Design Pattern | more...
Ph: +91 72000 69003
137b, 2nd st, shanthi nagar, Chrompet, Chennai -600044

BACK

              This is a sample program which explains about  merging JSONObject  and to addition  output of the program has been given below.

Example Program


import java.io.FileWriter;

import java.io.IOException;

import java.io.StringWriter;

import java.util.LinkedHashMap;

import java.util.LinkedList;

import java.util.Map;

import org.json.JSONArray;

import org.json.JSONObject;

public class WriteJsontoFile 

{

    public static void main(String[] args) 
    
    {
    	

         
         JSONArray list1 = new JSONArray();

         list1.put("foo");

         list1.put(new Integer(100));

         list1.put(new Double(1000.21));

         

         JSONArray list2 = new JSONArray();

         list2.put(new Boolean(true));

         list2.put(null);

         list2.putAll(list1);

         System.out.print(list2);

     }
   }



Output

[true,null,”foo”,100,1000.21]

BACK

Filed in: JSON Tutorial

Comments are closed.