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.
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 [] { 1, 2, 4, 8})); } }
1729 "BTC" [1,2,4,8]