Skip to main content
Skip table of contents

Three Way Merge Request

To invoke a Three Way Merge you POST a request in the structured JSON format or using multipart/form-dataTo understand how the three way merge process works, refer to Three Way Merge Guide.

End point
CODE
POST /api/json/v1/three-way-merge

JSON Request

Request
JS
{
  "ancestor": {
    "type": "http",
    "uri": "https://bitbucket.org/deltaxml/json-compare/raw/af425f2ce7c102433299f1c61a60d46f02d88ee3/Sample%20JSON/Server_Status_Testing/f1.json"
  },
  "edit1": {
    "type": "http",
    "uri": "https://bitbucket.org/deltaxml/json-compare/raw/af425f2ce7c102433299f1c61a60d46f02d88ee3/Sample%20JSON/Server_Status_Testing/f2.json"
  },
  "edit2": {
    "type": "http",
    "uri": "https://bitbucket.org/deltaxml/json-compare/raw/dc04a29ffb70a6fdad88d9126b9dc6dd9092267e/Sample%20JSON/Server_Status_Testing/f3.json"
  },
  "wordByWord": "false",
  "arrayAlignment": "typeWithValuePriority",
  "threeWayMergeMode": "showConflicts"
}

The request allows the parameters to be changed from their default values.

The response below indicates the merge result describing the changes between the inputs specified in the request. 

Response
XML
HTTP/1.1 200 Created
{
    "dx_deltaJSON": {
        "dx_data_sets": "A!=B",
        "dx_deltaJSON_type": "three-way-merge",
        "dx_deltaJSON_metadata": {
            "operation": {
                "type": "three-way-merge",
                "input-format": "json_uris",
                "output-format": "JSON"
            },
            "parameters": {
                "arrayAlignment": "typeWithValuePriority",
                "threeWayMergeMode": "showConflicts",
                "wordByWord": false
            }
        },
        "dx_deltaJSON_delta": {
            "a": {
                "dx_delta": {
                    "A": 2,
                    "B": 3
                }
            }
        }
    }
}

The example above shows how comparison inputs could be specified using a HTTP URL. The request can contain different types of objects according to the types of data being processed. This is described in more detail in  the I/O types page

Form Input

In addition to requests in structured JSON format, multipart/form-data can also be used.

For example:

Request
TEXT
POST /api/json/v2/three-way-merge HTTP/1.1
Content-Type: multipart/form-data; boundary=boundary-id
Content-Length: number_of_bytes_in_entire_request_body

--boundary-id
Content-Disposition: ancestor; filename="ancestor.json"
Content-Size: 98344
Content-Type: application/json

... JSON  ...
--boundary-id
Content-Disposition: edit1; filename="edit1.json"
Content-Size: 92224
Content-Type: application/json

... JSON  ...
--boundary-id
Content-Disposition: edit2; filename="edit2.json"
Content-Size: 92224
Content-Type: application/json

... JSON  ...
--boundary-id

Content-Disposition: form-data; name="wordByWord"
true
--boundary-id
Content-Disposition: form-data; name="arrayAlignment"
typeWithValuePriority
--boundary-id
Content-Disposition: form-data; name="threeWayMergeMode"
resolveUsingEdit1
--boundary-id

Three Way Merge Model

When specifying a comparison, these are the various available objects:

Object

Description

ancestor

(required)

Ancestor JSON input to a merge

See this page for the various I/O types available. 

edit1

(required)

Second JSON input to a merge, created by amending the ancestor version.

See this page for the various I/O types available. 

edit2

(required)

Third JSON input to a merge, created by amending the ancestor version.

See this page for the various I/O types available.

For more details about parameters, refer Three Way Merge Parameters.

Parameter

Type

Default

Description

wordByWord

boolean

false

Strings can be compared by whole string equality, or more granular word by word level.

arrayAlignment

string

orderless

Merging of arrays is controlled by how items in the arrays match together.

Available Options:

  • positionPriority

  • typeWithValuePriority

  • orderless

threeWayMergeMode

string

showConflicts

Output format describing how to show changes

Available Options:

  • showConflicts

  • resolveUsingEdit1 - when there are conflicts, choose the version present in edit1

  • resolveUsingEdit2 - when there are conflicts, choose the version present in edit2

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.