View RSS Feed

My Java Tips

Java to JSON

Rate this Entry
by , 10-30-2011 at 05:43 PM (894 Views)
Creating JSON or XML from Java is simple. I'll show some short code sample.



Java Code:
Person p = new Person();
JSONSerializer serializer = new JSONSerializer();
String json = serializer.serialize( p );
Created JSON String:

Java Code:
 {
   "class": "Person",
   "name": "William Shakespeare",
   "birthday": -12802392000000,
   "nickname": "Bill"
}

Submit "Java to JSON" to Facebook Submit "Java to JSON" to Digg Submit "Java to JSON" to del.icio.us Submit "Java to JSON" to StumbleUpon Submit "Java to JSON" to Google

Tags: None Add / Edit Tags
Categories
XML

Comments