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 of JSONArray and write to the writer PrintWriter.
    static void writeToConsumer​(java.io.PrintWriter writer, org.json.JSONObject jsonObject)
    Make a string from the contents of JSONObject and write to the writer PrintWriter.
    static void writeToConsumer​(org.json.JSONArray arr, java.util.function.Consumer<java.lang.Character> consumer)
    Make a string from the contents of JSONArray.
    static void writeToConsumer​(org.json.JSONObject obj, java.util.function.Consumer<java.lang.Character> consumer)
    Make a string from the contents of JSONObject.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • writeToConsumer

      public static void writeToConsumer​(org.json.JSONObject obj, java.util.function.Consumer<java.lang.Character> consumer) throws org.json.JSONException
      Make a string from the contents of JSONObject.
      Parameters:
      obj - JSONObject
      consumer - To consume a printable, displayable, transmittable representation of the JSONObject, 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.JSONException
      Make a string from the contents of JSONArray. Warning: This method assumes that the data structure is acyclical.
      Parameters:
      arr - JSONArray.
      consumer - To consume a printable, displayable, transmittable representation of the JSONArray, 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
      Parameters:
      string - A String
      consumer -
    • writeToConsumer

      public static void writeToConsumer​(java.io.PrintWriter writer, org.json.JSONArray jsonArray)
      Make a string from the contents of JSONArray and write to the writer PrintWriter. Warning: This method assumes that the data structure is acyclical.
      Parameters:
      writer - an object of PrintWriter to write generated String from jsonArray contents
      jsonArray - JSONArray.
    • writeToConsumer

      public static void writeToConsumer​(java.io.PrintWriter writer, org.json.JSONObject jsonObject)
      Make a string from the contents of JSONObject and write to the writer PrintWriter.
      Parameters:
      writer - an object of PrintWriter to write generated String from jsonObject contents
      jsonObject - JSONObject