Class JSONValue

java.lang.Object
org.jose4j.json.internal.json_simple.JSONValue

public class JSONValue extends Object
Author:
(originally) FangYidong [email protected]
  • Constructor Details

    • JSONValue

      public JSONValue()
  • Method Details

    • parse

      public static Object parse(Reader in)
      Deprecated.
      this method may throw an Error instead of returning null; please use parseWithException(Reader) instead
      Parse JSON text into java object from the input source. Please use parseWithException() if you don't want to ignore the exception.
      Parameters:
      in - Reader
      Returns:
      Instance of the following: org.jose4j.json.org.json.json_simple.JSONObject, org.jose4j.json.org.json.json_simple.JSONArray, java.lang.String, java.lang.Number, java.lang.Boolean, null
      See Also:
    • parse

      public static Object parse(String s)
      Deprecated.
      this method may throw an Error instead of returning null; please use parseWithException(String) instead
      Parse JSON text into java object from the given string. Please use parseWithException() if you don't want to ignore the exception.
      Parameters:
      s - String
      Returns:
      Instance of the following: org.jose4j.json.org.json.json_simple.JSONObject, org.jose4j.json.org.json.json_simple.JSONArray, java.lang.String, java.lang.Number, java.lang.Boolean, null
      See Also:
    • parseWithException

      public static Object parseWithException(Reader in) throws IOException, ParseException
      Parse JSON text into java object from the input source.
      Parameters:
      in - Reader
      Returns:
      Instance of the following: org.jose4j.json.org.json.json_simple.JSONObject, org.jose4j.json.org.json.json_simple.JSONArray, java.lang.String, java.lang.Number, java.lang.Boolean, null
      Throws:
      IOException - IOException
      ParseException - ParseException
      See Also:
    • parseWithException

      public static Object parseWithException(String s) throws ParseException
      Throws:
      ParseException
    • writeJSONString

      public static void writeJSONString(Object value, Writer out) throws IOException
      Encode an object into JSON text and write it to out.

      If this object is a Map or a List, and it's also a JSONStreamAware or a JSONAware, JSONStreamAware or JSONAware will be considered firstly.

      DO NOT call this method from writeJSONString(Writer) of a class that implements both JSONStreamAware and (Map or List) with "this" as the first parameter, use JSONObject.writeJSONString(Map, Writer) or JSONArray.writeJSONString(List, Writer) instead.

      Parameters:
      value - value
      out - Writer
      Throws:
      IOException - IOException
      See Also:
    • toJSONString

      public static String toJSONString(Object value)
      Convert an object to JSON text.

      If this object is a Map or a List, and it's also a JSONAware, JSONAware will be considered firstly.

      DO NOT call this method from toJSONString() of a class that implements both JSONAware and Map or List with "this" as the parameter, use JSONObject.toJSONString(Map) or JSONArray.toJSONString(List) instead.

      Parameters:
      value - Object
      Returns:
      JSON text, or "null" if value is null or it's an NaN or an INF number.
      See Also:
    • escape

      public static String escape(String s)
      Escape quotes, \, /, \r, \n, \b, \f, \t and other control characters (U+0000 through U+001F).
      Parameters:
      s - String
      Returns:
      string