Class JsonMergeUtils

java.lang.Object
com.api.jsonata4java.expressions.utils.JsonMergeUtils
All Implemented Interfaces:
Serializable

public class JsonMergeUtils extends Object implements 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
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    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!)

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 object
      y - Json object
      Returns:
      merged Json object