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 parsing a JSON string.
package com.bethecoder.tutorials.json_simple.tests; import org.json.simple.JSONObject; import org.json.simple.JSONValue; public class ParseJsonString { /** * @param args */ public static void main(String[] args) { String jsonStr = "{ \"age\" : \"2\", \"name\" : \"Sriram\", \"hobby\" : \"painting\" }"; JSONObject jsonObj = (JSONObject) JSONValue.parse(jsonStr); System.out.println(jsonObj); } }
{"name":"Sriram","age":"2","hobby":"painting"}