All Downloads are FREE. Search and download functionalities are using the official Maven repository.

public.javadoc.org.spincast.core.json.JsonObjectDefault.html Maven / Gradle / Ivy

There is a newer version: 2.2.0
Show newest version






JsonObjectDefault (org.spincast:spincast-framework 1.0.0 API)












org.spincast.core.json

Class JsonObjectDefault

    • Field Detail

      • logger

        protected final org.slf4j.Logger logger
    • Method Detail

      • setNoKeyParsing

        public JsonObject setNoKeyParsing(String jsonPath,
                                          Object value)
        Description copied from interface: JsonObject
        Sets an element at the specified key, without parsing this key as a JsonPath.

        If the element to add is not of a native type, then the element is converted before being added. Once the element is converted and added, a modification of the original object won't affect this element, and vice-versa.

        If the element to add is a JsonObject or a JsonArray and is immutable, it will be cloned. Doing so, we can make sure the JsonArray is always fully mutable or fully immutable.

        If the element implements ToJsonObjectConvertible, it will be converted to a JsonObject using the associated conversion method. If it implements ToJsonArrayConvertible, it will be converted to an JsonArray using the associated conversion method.

        Those are the types of objects that will be converted to a JsonArray instead of a JsonObject, if no conversion interface is implemented :

        • A Collection
        • An array
        Specified by:
        setNoKeyParsing in interface JsonObject
      • setNoKeyParsing

        public JsonObject setNoKeyParsing(String jsonPath,
                                          Object value,
                                          boolean clone)
        Description copied from interface: JsonObject
        Sets an element at the specified key, without parsing this key as a JsonPath.

        If the element to add is not of a native type, then the element is converted before being added. Once the element is converted and added, a modification of the original object won't affect this element, and vice-versa.

        If the element to add is a JsonObject or a JsonArray and is immutable, it will be cloned. Doing so, we can make sure the JsonArray is always fully mutable or fully immutable.

        If the element implements ToJsonObjectConvertible, it will be converted to a JsonObject using the associated conversion method. If it implements ToJsonArrayConvertible, it will be converted to an JsonArray using the associated conversion method.

        Those are the types of objects that will be converted to a JsonArray instead of a JsonObject, if no conversion interface is implemented :

        • A Collection
        • An array
        Specified by:
        setNoKeyParsing in interface JsonObject
        clone - if true, and the element to add is a JsonObject or JsonArray, a clone will be made before being added. If that case, any modification to the original element won't affect the added one, and vice-versa. If the element is immutable then it will always be cloned. Doing so, we can make sure a JsonObject is always fully mutable or fully immutable.
      • merge

        public JsonObject merge(Map<String,?> map)
        Description copied from interface: JsonObject
        Merges all the specified Map elements in the JsonObject. The keys are parsed as JsonPaths. Overwrites existing elements at the specified JsonPaths.

        Note that the JsonObject and JsonArray objects from the source will be added as is, so any modification to them WILL affect the added elements, and vise-versa. There is an exception though : if the element to add is immutable then it will always be cloned. Doing so, we can make sure a JsonObject is always fully mutable or fully immutable.

        If an element to is not of a native type, then the element is converted before being added. Once the element is converted and added, a modification of the original object won't affect this element, and vice-versa.

        If an element to is a JsonObject or a JsonArray and is immutable, it will be cloned. Doing so, we can make sure the JsonArray is always fully mutable or fully immutable.

        If an element implements ToJsonObjectConvertible, it will be converted to a JsonObject using the associated conversion method. If it implements ToJsonArrayConvertible, it will be converted to an JsonArray using the associated conversion method.

        Those are the types of objects that will be converted to a JsonArray instead of a JsonObject, if no conversion interface is implemented :

        • A Collection
        • An array
        Specified by:
        merge in interface JsonObject
      • merge

        public JsonObject merge(Map<String,?> map,
                                boolean clone)
        Description copied from interface: JsonObject
        Merges all the specified Map elements in the JsonObject. The keys are parsed as JsonPaths. Overwrites existing elements at the specified JsonPaths.

        If an element to is not of a native type, then the element is converted before being added. Once the element is converted and added, a modification of the original object won't affect this element, and vice-versa.

        If an element to is a JsonObject or a JsonArray and is immutable, it will be cloned. Doing so, we can make sure the JsonArray is always fully mutable or fully immutable.

        If an element implements ToJsonObjectConvertible, it will be converted to a JsonObject using the associated conversion method. If it implements ToJsonArrayConvertible, it will be converted to an JsonArray using the associated conversion method.

        Those are the types of objects that will be converted to a JsonArray instead of a JsonObject, if no conversion interface is implemented :

        • A Collection
        • An array
        Specified by:
        merge in interface JsonObject
        clone - if true, a clone of any JsonObject or JsonArray will be made before being added. If that case, any modification to the original elements won't affect the added elements, and vice-versa. If the element is immutable then it will always be cloned. Doing so, we can make sure a JsonObject is always fully mutable or fully immutable.
      • merge

        public JsonObject merge(JsonObject jsonObj)
        Description copied from interface: JsonObject
        Merges the specified JsonObject properties in the current object. Overwrites elements of the same JsonPaths.

        Note that the elements from the source are added as is, so any modification to them WILL affect the added element, and vise-versa. There is an exception though : if an element to add is immutable then it will always be cloned. Doing so, we can make sure a JsonObject is always fully mutable or fully immutable.

        Specified by:
        merge in interface JsonObject
      • merge

        public JsonObject merge(ToJsonObjectConvertible obj)
        Description copied from interface: JsonObject
        Transforms the specifie3d object to JsonObject and merges its properties in the current object. Overwrites elements of the same JsonPaths.
        Specified by:
        merge in interface JsonObject
      • merge

        public JsonObject merge(JsonObject jsonObj,
                                boolean clone)
        Description copied from interface: JsonObject
        Merges the specified JsonObject properties in the current object. Overwrites elements of the same JsonPaths.
        Specified by:
        merge in interface JsonObject
        clone - if true, a clone of the original JsonObject will be made before being added. If that case, any modification to the original object won't affect the added element, and vice-versa. If an element is immutable then it will always be cloned. Doing so, we can make sure a JsonObject is always fully mutable or fully immutable.
      • remove

        public JsonObject remove(String jsonPath)
        Removes a property at JsonPath from the object.
        Specified by:
        remove in interface JsonObjectOrArray
        Returns:
        the current object (fluent style).
      • removeNoKeyParsing

        public JsonObject removeNoKeyParsing(String key)
        Description copied from interface: JsonObject
        Removes a element from the object. The key is used as is, without being parsed as a JsonPath.
        Specified by:
        removeNoKeyParsing in interface JsonObject
      • isElementExistsNoKeyParsing

        public boolean isElementExistsNoKeyParsing(String key)
        Description copied from interface: JsonObject
        Does the JsonObject contain an element at the specified key? The key is considered as is, without being parsed as a JsonPath.
        Specified by:
        isElementExistsNoKeyParsing in interface JsonObject
      • convertToPlainMap

        public Map<String,Object> convertToPlainMap()
        Description copied from interface: JsonObject
        Converts the JsonObject to a plain Map. All JsonObject children will be converted to Maps and all JsonArray children will be converted to Lists.
        Specified by:
        convertToPlainMap in interface JsonObject
      • convert

        public <T> T convert(Class<T> clazz)
        Description copied from interface: JsonObject
        Converts the JsonObject to an instance of the specified T type.

        This uses JsonManager#fromJsonString and may throw an exception if it is unable to do the conversion.

        Specified by:
        convert in interface JsonObject
      • isEquivalentTo

        public boolean isEquivalentTo(JsonObject other)
        Description copied from interface: JsonObject
        Compares the current JsonObject to the specified one and returns true if they are equivalent. To be equivalent, all their elements must be so too.

        An element is equivalent to the other if they can be converted to the¸ same type, and then if they are equals.

        For example, the String "123" is equivalent to new BigDecimal("123") or to 123L.

        Specified by:
        isEquivalentTo in interface JsonObject

Copyright © 2019. All rights reserved.





© 2015 - 2024 Weber Informatics LLC | Privacy Policy