Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge JSON Instances #4

Open
xmljim opened this issue Feb 19, 2021 · 0 comments
Open

Merge JSON Instances #4

xmljim opened this issue Feb 19, 2021 · 0 comments
Labels
enhancement New feature or request

Comments

@xmljim
Copy link
Owner

xmljim commented Feb 19, 2021

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.
@xmljim xmljim added the enhancement New feature or request label Feb 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant