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

Parse JSON String 

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.

File Name  :  
com/bethecoder/tutorials/json_simple/tests/ParseJsonString.java 
Author  :  Sudhakar KV
Email  :  [email protected]
   
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 = (JSONObjectJSONValue.parse(jsonStr);
    System.out.println(jsonObj);
  }

}
   

It gives the following output,
{"name":"Sriram","age":"2","hobby":"painting"}



 
  


  
bl  br