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

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 serializing a simple JSON Array.

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

import org.json.simple.JSONArray;
import org.json.simple.JSONObject;

public class JsonArrayTest {

  /**
   @param args
   */
  public static void main(String[] args) {

    JSONArray jsonArray = new JSONArray();
    jsonArray.add("one");
    jsonArray.add("two");
    jsonArray.add("three");
    System.out.println(jsonArray);
    
    JSONObject jsonObj = new JSONObject();
    jsonObj.put("name""Sriram");
    jsonObj.put("age"2);
    jsonObj.put("hobby""painting");
    jsonArray.add(jsonObj);
    
    System.out.println(jsonArray);
  }

}
   

It gives the following output,
["one","two","three"]
["one","two","three",{"age":2,"name":"Sriram","hobby":"painting"}]


                    Print

   



Books Recommendation

 
 
bl  br