Class JSONUtil
java.lang.Object
de.uplanet.lucy.server.auxiliaries.JSONUtil
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final class
A builder to create JSON output. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptioncreateBuilder
(Writer p_writer, boolean p_bAutoEnableWrite) Create a JSON builder.de.uplanet.lucy.server.auxiliaries.net.HttpRequest
Create a JSON HTTP request object.Escape quotes, \, /, \r, \n, \b, \f, \t and other control characters (U+0000 through U+001F).org.json.simple.JSONArray
newArray()
Create a new JSON array.org.json.simple.JSONObject
Create a new JSON object.org.json.simple.JSONObject
Create a new JSON object.Parse a JSON object from a character stream.parse
(CharSequence p_chseq) Parse a JSON object from a character sequence.parseFromFile
(String p_strPath) Parse a JSON object from a file.toJSONString
(Object p_value) Convert an object to a JSON string.void
Convert an object to a JSON string and write it to a character stream.void
writeJSONString
(Object p_value, Writer p_writer) Deprecated.
-
Constructor Details
-
JSONUtil
public JSONUtil()
-
-
Method Details
-
newObject
public org.json.simple.JSONObject newObject()Create a new JSON object.- Returns:
- The new object.
-
newObject
Create a new JSON object.- Parameters:
p_map
- A map that represents the JSON object.- Returns:
- The new object.
-
newArray
public org.json.simple.JSONArray newArray()Create a new JSON array.- Returns:
- The new array.
-
escape
Escape quotes, \, /, \r, \n, \b, \f, \t and other control characters (U+0000 through U+001F).- Parameters:
p_strValue
- The string to be escaped.- Returns:
- The string with escaped characters.
-
toJSONString
Convert an object to a JSON string.- Parameters:
p_value
- The object.- Returns:
- The object in JSON serialized form.
-
writeJSONString
Deprecated.UsewriteJSON(Writer, Object)
instead.- Throws:
IOException
-
writeJSON
Convert an object to a JSON string and write it to a character stream.- Parameters:
p_writer
- The output stream.p_value
- The object.- Throws:
IOException
-
createBuilder
Create a JSON builder.This is the most flexible way to create JSON output from a variety of input data.
If the parameter
p_bAutoEnableWrite
istrue
the builder will automatically enable and disable writing on the underlying stream if the stream had previously put in the ignore-write mode.- Parameters:
p_writer
- The output stream.p_bAutoEnableWrite
-true
if the builder should manage writing on the underlying stream, orfalse
otherwise.- Returns:
- A JSON builder that writes to the given output stream.
- Since:
- Intrexx 7.0
-
parse
Parse a JSON object from a character stream.- Parameters:
p_reader
- The input stream.- Returns:
- An instance of the following:
org.json.simple.JSONObject
,org.json.simple.JSONArray
,java.lang.String
,java.lang.Number
,java.lang.Boolean
, ornull
.
-
parse
Parse a JSON object from a character sequence.- Parameters:
p_chseq
- The text input.- Returns:
- An instance of the following:
org.json.simple.JSONObject
,org.json.simple.JSONArray
,java.lang.String
,java.lang.Number
,java.lang.Boolean
, ornull
.
-
parseFromFile
public Object parseFromFile(String p_strPath) throws IOException, org.json.simple.parser.ParseException Parse a JSON object from a file.- Parameters:
p_strPath
- The path to the file to be parsed.- Returns:
- An instance of the following:
org.json.simple.JSONObject
,org.json.simple.JSONArray
,java.lang.String
,java.lang.Number
,java.lang.Boolean
, ornull
.
- Throws:
org.json.simple.parser.ParseException
- If the given input could not be parsed as JSON.IOException
- If an I/O error occurred.
-
createJSONHttpRequest
public de.uplanet.lucy.server.auxiliaries.net.HttpRequest createJSONHttpRequest()Create a JSON HTTP request object.- Returns:
- A JSON HTTP request object.
-
writeJSON(Writer, Object)
instead.