com.aelitis.azureus.util
Class JSONUtils

java.lang.Object
  extended by com.aelitis.azureus.util.JSONUtils

public class JSONUtils
extends Object

Author:
TuxPaper

Constructor Summary
JSONUtils()
           
 
Method Summary
static Map decodeJSON(String json)
          decodes JSON formatted text into a map.
static String encodeToJSON(Collection list)
           
static String encodeToJSON(Map map)
          Encodes a map into a JSON formatted string.
static JSONObject encodeToJSONObject(Map map)
          encodes a map into a JSONObject.
static void main(String[] args)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JSONUtils

public JSONUtils()
Method Detail

decodeJSON

public static Map decodeJSON(String json)
decodes JSON formatted text into a map.

Returns:
Map parsed from a JSON formatted string

If the json text is not a map, a map with the key "value" will be returned. the value of "value" will either be an List, String, Number, Boolean, or null

if the String is formatted badly, null is returned


encodeToJSONObject

public static JSONObject encodeToJSONObject(Map map)
encodes a map into a JSONObject.

It's recommended that you use encodeToJSON(Map) instead

Parameters:
map -
Returns:
Since:
3.0.1.5

encodeToJSON

public static String encodeToJSON(Map map)
Encodes a map into a JSON formatted string.

Handles multiple layers of Maps and Lists. Handls String, Number, Boolean, and null values.

Parameters:
map - Map to change into a JSON formatted string
Returns:
JSON formatted string
Since:
3.0.1.5

encodeToJSON

public static String encodeToJSON(Collection list)

main

public static void main(String[] args)