Class StrictEncodingJSONFormatter
java.lang.Object
com.onenetwork.platform.tools.util.StrictEncodingJSONFormatter
public class StrictEncodingJSONFormatter
extends java.lang.Object
Make an JSON text of
JSONObject
or JSONArray
.
Non alpha-numeric Character
were encoded using Unicode value.-
Constructor Summary
Constructors Constructor Description StrictEncodingJSONFormatter()
-
Method Summary
Modifier and Type Method Description static void
quote(java.lang.String string, java.util.function.Consumer<java.lang.Character> consumer)
Produce a string in double quotes with backslash sequences in all the right places.static void
writeToConsumer(java.io.PrintWriter writer, org.json.JSONArray jsonArray)
Make a string from the contents ofJSONArray
and write to the writerPrintWriter
.static void
writeToConsumer(java.io.PrintWriter writer, org.json.JSONObject jsonObject)
Make a string from the contents ofJSONObject
and write to the writerPrintWriter
.static void
writeToConsumer(org.json.JSONArray arr, java.util.function.Consumer<java.lang.Character> consumer)
Make a string from the contents ofJSONArray
.static void
writeToConsumer(org.json.JSONObject obj, java.util.function.Consumer<java.lang.Character> consumer)
Make a string from the contents ofJSONObject
.
-
Constructor Details
-
StrictEncodingJSONFormatter
public StrictEncodingJSONFormatter()
-
-
Method Details
-
writeToConsumer
public static void writeToConsumer(org.json.JSONObject obj, java.util.function.Consumer<java.lang.Character> consumer) throws org.json.JSONExceptionMake a string from the contents ofJSONObject
.- Parameters:
obj
-JSONObject
consumer
- To consume a printable, displayable, transmittable representation of theJSONObject
, beginning with{
(left brace) and ending with}
(right brace).- Throws:
org.json.JSONException
- If the value is or contains an invalid number.
-
writeToConsumer
public static void writeToConsumer(org.json.JSONArray arr, java.util.function.Consumer<java.lang.Character> consumer) throws org.json.JSONExceptionMake a string from the contents ofJSONArray
. Warning: This method assumes that the data structure is acyclical.- Parameters:
arr
-JSONArray
.consumer
- To consume a printable, displayable, transmittable representation of theJSONArray
, beginning with[
(left square bracket) and ending with]
(right square bracket).- Throws:
org.json.JSONException
- If the array contains an invalid number.
-
quote
public static void quote(java.lang.String string, java.util.function.Consumer<java.lang.Character> consumer)Produce a string in double quotes with backslash sequences in all the right places. A backslash will be inserted within , allowing JSON text to be delivered in HTML. In JSON text, a string cannot contain a control character or an unescaped quote or backslash.- Parameters:
string
- A Stringconsumer
-
-
writeToConsumer
public static void writeToConsumer(java.io.PrintWriter writer, org.json.JSONArray jsonArray)Make a string from the contents ofJSONArray
and write to the writerPrintWriter
. Warning: This method assumes that the data structure is acyclical.- Parameters:
writer
- an object ofPrintWriter
to write generated String from jsonArray contentsjsonArray
-JSONArray
.
-
writeToConsumer
public static void writeToConsumer(java.io.PrintWriter writer, org.json.JSONObject jsonObject)Make a string from the contents ofJSONObject
and write to the writerPrintWriter
.- Parameters:
writer
- an object ofPrintWriter
to write generated String from jsonObject contentsjsonObject
-JSONObject
-