Skip to content

Merge JSON Instances #4

@xmljim

Description

@xmljim

As a JSON Developer I can merge a JSON instance into another JSON instance to create a single instance

Acceptance Criteria

  • Definitions:

    • Primary: The JSON instance that will be used as the base instance for comparison
    • Secondary: The JSON instance the contains data to be pulled into the primary instance.
  • JSONObject properties

    • Where there are no conflicts between the primary and secondary instances, i.e., , the data from the secondary instance is pulled into the primary
    • Where properties are equivalent, no additional action is needed
    • Where there are conflicts between properties of the same name and context, there will be three different conflict strategies that can be applied
      • Accept Secondary: The value of the secondary instance overrides the primary instance
      • Accept Primary: The value of the primary instance remains
      • Append: Append the value of the secondary using a new key (named [key name]_append)
    • Where properties are not equivalent, then it will depend on the data type
      • If the data types are the same (Primitive, Object, Array) then
        • For primitive value types (e.g., Strings, Numbers, Boolean, Null), the selected conflict strategy will be applied
        • For JSONObjects, the same merge rules will be applied recursively
        • For JSONArrays, the JSONArray merging rules will be applied recursively
      • If the data types are different, then the selected conflict strategy will be applied
  • JSONArray items

    • Items will be evaluated by index position
    • The following Conflict Strategies can be applied to items
      • Insert Before: Insert the conflict item in the secondary array into the primary just before the item in the current position
      • Insert After: Insert the conflict item from the secondary array into the primary just after the item in the current position
      • Append: Append the conflict item from the secondary array to the end of the primary array
    • If both items at the same position are JSONObjects, then merging rules for JSONObjects are applied
    • If both items at the same position are JSONArrays, the the arrays will be merged using the JSONArray merging rules
    • If the items at the same position are a different data and value type then the selected Conflict Strategy will be applied.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions