Class JSON


  • public class JSON
    extends java.lang.Object
    A class that is the front door to the JSON subsystem
    • Constructor Summary

      Constructors 
      Constructor Description
      JSON()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static JsonObject buildObject​(java.util.function.Consumer<JsonBuilder> setup)
      Build a JsonObject.
      static JsonValue copy​(JsonValue arg)
      Create a safe copy of a JsonValue.
      static JsonObject parse​(java.io.InputStream input)
      Parse a complete JSON object
      static JsonObject parse​(java.lang.String string)
      Parse a complete JSON object
      static JsonValue parseAny​(java.io.InputStream input)
      Parse any JSON value, not just an object, from an input stream
      static JsonValue parseAny​(java.lang.String string)
      Parse any JSON value, not just an object, from a file
      static JsonObject read​(java.lang.String filename)
      Read a JSON object from a file
      static JsonValue readAny​(java.lang.String filename)
      Read any JSON value, not just an object, from a file
      static java.lang.String toString​(JsonValue jValue)
      JsonValue to a formatted, multiline string
      static java.lang.String toStringFlat​(JsonValue jValue)
      JsonValue to a string with no newlines
      static void write​(java.io.OutputStream output, JsonValue jValue)
      Write out a JSON value - pass a JSON Object to get legal exchangeable JSON
      static void write​(org.apache.jena.atlas.io.IndentedWriter output, JsonValue jValue)
      Write out a JSON value - pass a JSON Object to get legal exchangeable JSON
      static void write​(JsonValue jValue)
      Write out a JSON value - pass a JSON Object to get legal exchangeable JSON
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • JSON

        public JSON()
    • Method Detail

      • parse

        public static JsonObject parse​(java.io.InputStream input)
        Parse a complete JSON object
      • parse

        public static JsonObject parse​(java.lang.String string)
        Parse a complete JSON object
      • parseAny

        public static JsonValue parseAny​(java.io.InputStream input)
        Parse any JSON value, not just an object, from an input stream
      • parseAny

        public static JsonValue parseAny​(java.lang.String string)
        Parse any JSON value, not just an object, from a file
      • read

        public static JsonObject read​(java.lang.String filename)
        Read a JSON object from a file
      • readAny

        public static JsonValue readAny​(java.lang.String filename)
        Read any JSON value, not just an object, from a file
      • toString

        public static java.lang.String toString​(JsonValue jValue)
        JsonValue to a formatted, multiline string
      • toStringFlat

        public static java.lang.String toStringFlat​(JsonValue jValue)
        JsonValue to a string with no newlines
      • write

        public static void write​(java.io.OutputStream output,
                                 JsonValue jValue)
        Write out a JSON value - pass a JSON Object to get legal exchangeable JSON
      • write

        public static void write​(org.apache.jena.atlas.io.IndentedWriter output,
                                 JsonValue jValue)
        Write out a JSON value - pass a JSON Object to get legal exchangeable JSON
      • write

        public static void write​(JsonValue jValue)
        Write out a JSON value - pass a JSON Object to get legal exchangeable JSON
      • copy

        public static JsonValue copy​(JsonValue arg)
        Create a safe copy of a JsonValue.

        If the JsonValue is a structure (object or array), copy the structure recursively.

        If the JsonValue is a primitive (string, number, boolean or null), it is immutable so return the same object.

      • buildObject

        public static JsonObject buildObject​(java.util.function.Consumer<JsonBuilder> setup)
        Build a JsonObject. The outer object is created and then the setup function called to fill in the contents.
         buildObject(builder->{
             builder.pair("key", 1234);
         });
         
        Parameters:
        setup -
        Returns:
        JsonObject