Package convex.java
Class JSON
java.lang.Object
convex.java.JSON
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ObjectConverts a CVM Value to a Java JSON representationstatic <T> Tparse(InputStream content) Parses a JSON input streamstatic <T> TConverts a string to a JSON ValueConverts a string to JSON.static StringtoPrettyString(Object value) Converts an object to a pretty-printed JSON string representation suitable for human consumptionstatic StringConverts a Java Object to an efficient JSON string representation
-
Constructor Details
-
JSON
public JSON()
-
-
Method Details
-
toMap
Converts a string to JSON.- Parameters:
jsonString- A string containing a valid JSON Object representation- Returns:
- A map representing the JSON object
- Throws:
IllegalArgumentException- In case of JSON parsing error
-
parse
Converts a string to a JSON Value- Type Parameters:
T- A type parameter for the type of object returned.- Parameters:
jsonString- A string containing valid JSON- Returns:
- T A java object representing the JSON provided
- Throws:
IllegalArgumentException- on JSON parsing error
-
toPrettyString
-
toString
Converts a Java Object to an efficient JSON string representation- Parameters:
value- Java Object to represent as a JSON String- Returns:
- JSON string representing the value
- Throws:
RuntimeException- on failure to create JSON from value
-
from
-
parse
Parses a JSON input stream- Type Parameters:
T- Return type- Parameters:
content- Any InputStream containing JSON content in UTF-8- Returns:
- Parsed JSON Object
-