tl  tr
  Home | Tutorials | Articles | Videos | Products | Tools | Search
Interviews | Open Source | Tag Cloud | Follow Us | Bookmark | Contact   
 JSON > JSON JAVA > JSONObject To XML

JSONObject To XML 

JSON (JavaScript Object Notation) is a lightweight text-based open standard designed for human-readable data interchange. Douglas Crockford has provided a reference implementation of JSON in Java at http://json.org/ useful for JSON serialization and deserialization. Click here to download the compiled library. The following example shows converting a JSONObject to XML.

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

import org.json.JSONException;
import org.json.JSONObject;
import org.json.XML;

public class Json2XML {

  /**
   @param args
   @throws JSONException 
   */
  public static void main(String[] argsthrows JSONException {
    String jsonStr = "{ employee : { age:32, name : ABC DEF,  married:true}}";
    JSONObject jsonObj = new JSONObject(jsonStr);
    System.out.println(XML.toString(jsonObj));
  }

}
   

It gives the following output,
File Name  :  OUTPUT



 
  


  
bl  br