tl  tr
  Home | Tutorials | Articles | Videos | Products | Tools | Search
Interviews | Open Source | Tag Cloud | Follow Us | Bookmark | Contact   
 JSON > GOOGLE GSON > JSON Object

JSON Object 

Google-gson is a java library from Google for encoding and decoding JSON text. Get the latest binaries from http://code.google.com/p/google-gson/. The following example shows serializing a simple JSON object.

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

import com.google.gson.Gson;


public class First {

  /**
   @param args
   */
  public static void main(String[] args) {
    Gson gson = new Gson();
    System.out.println(gson.toJson(1729));          
    System.out.println(gson.toJson("BTC"));      
    System.out.println(gson.toJson(new int [] { 1248}));
  }

}
   

It gives the following output,
1729
"BTC"
[1,2,4,8]



 
  


  
bl  br