Class JsonMergeUtils
java.lang.Object
com.api.jsonata4java.expressions.utils.JsonMergeUtils
- All Implemented Interfaces:
Serializable
A utility for merging arbitrary JSON trees. Used during default state
generation to combine explicit and implicit default values where necessary.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic com.fasterxml.jackson.databind.JsonNodemerge(com.fasterxml.jackson.databind.JsonNode x, com.fasterxml.jackson.databind.JsonNode y) Returns x "merged into" y If x is null (java null, not JSON null!)
-
Constructor Details
-
JsonMergeUtils
public JsonMergeUtils()
-
-
Method Details
-
merge
public static com.fasterxml.jackson.databind.JsonNode merge(com.fasterxml.jackson.databind.JsonNode x, com.fasterxml.jackson.databind.JsonNode y) Returns x "merged into" y If x is null (java null, not JSON null!), return y If y is (java null, not JSON null!), return x If both x and y are primitive (including JSON null!), return x (i.e. values in x take precedence over those in y) If x and y are of different types, return x If x and y are both objects, merge each field of x and y If an array field is set in both x and y, merge will be run on each element in turn. the length of the returned array will be max( length(x), length(y) ) See src/test/resources/JsonMergeUtilsTest.json for examples.- Parameters:
x- Json objecty- Json object- Returns:
- merged Json object
-