Package javax.json

Class Json


  • public final class Json
    extends Object
    • Method Detail

      • createObjectBuilder

        public static JsonObjectBuilder createObjectBuilder()
        Create an empty JsonObjectBuilder
        Since:
        1.0
      • createObjectBuilder

        public static JsonObjectBuilder createObjectBuilder​(JsonObject object)
        Creates a JSON object builder, initialized with the specified JsonObject.
        Since:
        1.1
      • createObjectBuilder

        public static JsonObjectBuilder createObjectBuilder​(Map<String,​Object> map)
        Creates a JSON object builder, initialized with the specified Map.
        Since:
        1.1
      • createArrayBuilder

        public static JsonArrayBuilder createArrayBuilder​(JsonArray initialData)
        Creates a JSON array builder, initialized with an initial content taken from a JsonArray
        Parameters:
        initialData - the initial array in the builder
        Returns:
        a JSON array builder
        Since:
        1.1
      • createArrayBuilder

        public static JsonArrayBuilder createArrayBuilder​(Collection<?> initialData)
        Creates a JSON array builder, initialized with an initial content
        Parameters:
        initialData - the initial array in the builder
        Returns:
        a JSON array builder
        Since:
        1.1
      • createValue

        public static JsonNumber createValue​(int value)
      • createValue

        public static JsonNumber createValue​(long value)
      • createValue

        public static JsonNumber createValue​(double value)
      • createPatch

        public static JsonPatch createPatch​(JsonArray array)
        Create a JsonPatch as defined in RFC-6902.
        Parameters:
        array - with the patch operations
        Returns:
        the JsonPatch based on the given operations
        Since:
        1.1
      • createPatchBuilder

        public static JsonPatchBuilder createPatchBuilder()
        Create a new JsonPatchBuilder
        Since:
        1.1
      • createPatchBuilder

        public static JsonPatchBuilder createPatchBuilder​(JsonArray initialData)
        Create a new JsonPatchBuilder
        Parameters:
        initialData - the initial patch operations
        Since:
        1.1
      • createMergePatch

        public static JsonMergePatch createMergePatch​(JsonValue patch)
        Creates JSON Merge Patch (RFC 7396) from a specified JsonValue. Create a merged patch by comparing the source to the target.

        Applying this JsonPatch to the source will give you the target.

        If you have a JSON like

         {
           "a": "b",
           "c": {
             "d": "e",
             "f": "g"
           }
         }
         

        Then you can change the value of "a" and removing "f" by sending:

         {
           "a":"z",
           "c": {
             "f": null
           }
         }
         
        Parameters:
        patch - the patch
        Returns:
        a JSON Merge Patch
        Since:
        1.1
      • createMergeDiff

        public static JsonMergePatch createMergeDiff​(JsonValue source,
                                                     JsonValue target)
        Create a JSON Merge Patch (RFC 7396) from the source and target JsonValues. Create a merged patch by comparing the source to the target.

        Applying this JsonPatch to the source will give you the target.

        If you have a JSON like

         {
           "a": "b",
           "c": {
             "d": "e",
             "f": "g"
           }
         }
         

        Then you can change the value of "a" and removing "f" by sending:

         {
           "a":"z",
           "c": {
             "f": null
           }
         }
         
        Parameters:
        source - the source
        target - the target
        Returns:
        a JSON Merge Patch
        Since:
        1.1
      • encodePointer

        public static String encodePointer​(String pointer)
        Parameters:
        pointer - to encode
        Returns:
        the properly encoded JsonPointer string
        Since:
        1.1
      • decodePointer

        public static String decodePointer​(String escapedPointer)
        Parameters:
        escapedPointer -
        Returns:
        the de-escaped JsonPointer
        Since:
        1.1