tl  tr
  Home | Tutorials | Articles | Videos | Products | Tools | Search
Open Source | Tag Cloud | Follow Us | Bookmark | Contact   
 
 JSON > JSON JAVA > JSON Append

JSON Append 

JSON (JavaScript Object Notation) is a lightweight text-based open standard designed for human-readable data interchange. Douglas Crockford has provided a reference implementation of JSON in Java at http://json.org/ useful for JSON serialization and deserialization. Click here to download the compiled library. The following example shows using append method of JSONObject. It appends values to JSONArray under a key.

File Name  :  
com/bethecoder/tutorials/json_java/tests/JsonAppend.java 
Author  :  Sudhakar KV
Email  :  kvenkatasudhakar@gmail.com
   
package com.bethecoder.tutorials.json_java.tests;

import org.json.JSONException;
import org.json.JSONObject;

public class JsonAppend {

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

    JSONObject jsonObj = new JSONObject();
    jsonObj.append("certificates""SCJA");
    System.out.println(jsonObj.toString(2));
    
    jsonObj.append("certificates""SCJP");
    jsonObj.append("certificates""SCWCD");
    System.out.println(jsonObj.toString(2));
  }

}
   

It gives the following output,
{"certificates": ["SCJA"]}

{"certificates": [
  "SCJA",
  "SCJP",
  "SCWCD"
]}


                    Print

   



Books Recommendation

 
 
bl  br