Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • Step 1: The anchor data and JSON payload are fetched as JSON strings.
  • Step 2: The JSON payload is compared to the JSON string from the anchor and all the newly added data nodes in JSON payload are extracted to a separate JSON string, while simultaneously removing this newly added data from the JSON payload.
  • Step 3: After step 2 the JSON payload will be split into two JSON strings, one containing the Unmodified, Updated and Deleted data and second containing only the Added data.
  • Step 4: The JSON string from anchor and the JSON string containing the Unmodified, Updated and Deleted data can then be parsed into DataNodes, as at this point, we can be sure that all the data in the particular JSON string will belong to the schema, which can then be used by the existing algorithm to find the delta. This part of delta report will contain the action, xpath and source/target data.
  • Step 5: The added data can then be put in the delta report, but since this approach assumes that all the added data nodes are not part of the schema, it is not possible to determine their xpath and hence the field for xpath can be redacted for added data nodes in this approach.

Exapmle:

JSON Data from AnchorJSON payloadAdded DataModified JSON payload after removing added data


Code Block
collapsetrue
{
  "test:bookstore": {
    "bookstore-name": "Chapters/Easons",
    "categories": [
      {
        "code": "01/1",
        "name": "SciFi",
        "books": [
          {
            "authors": [
              "Iain M. Banks"
            ],
            "lang": "en/it",
            "price": "895",
            "pub_year": "1994",
            "title": "Feersum Endjinn/Endjinn Feersum"
          },{
            "authors": [
              "Ursula K. Le Guin"
            ],
            "lang": "en",
            "price": "1099",
            "pub_year": "1999",
            "title": "Far Horizons"
          }
        ]
      },{
        "name": "Horror",
        "code": "03",
        "books": [
          {
            "authors": [
              "ABC"
            ],
            "lang": "en",
            "price": "699",
            "pub_year": "1995",
            "title": "Horror Book"
          }
        ]
      }
    ],
  }
}



Code Block
collapsetrue
{
  "test:bookstore": {
    "bookstore-name": "Chapters/Easons",
    "categories": [
      {
        "code": "01/1",
        "name": "SciFi",
        "books": [
          {
            "authors": [
              "Iain M. Banks"
            ],
            "lang": "en/it",
            "price": "895",
            "pub_year": "1994",
            "title": "Feersum Endjinn/Endjinn Feersum"
          },
          {
            "authors": [
              "Ursula K. Le Guin"
            ],
            "lang": "en",
            "price": "1099",
            "pub_year": "1999",
            "title": "Far Horizons"
          }
        ]
      },
      {
        "name": "kids",
        "code": "02",
        "books": [
          {
            "authors": [
              "Philip Pullman"
            ],
            "lang": "en",
            "price": "699",
            "pub_year": "1995",
            "title": "The Golden Compass"
          }
        ]
      },
      {
        "name": "Horror",
        "code": "03",
        "books": [
          {
            "authors": [
              "ABC"
            ],
            "lang": "en",
            "price": "699",
            "pub_year": "1995",
            "title": "Horror Book"
          }
        ]
      }
    ],
    "bookstore-phone": "123",
    "bookstore-emp": { }
  },
  "test:bookstore2": {
    "bookstore-name": "Test"
  }
}



Code Block
collapsetrue
{
  "test:bookstore" : {
    "categories" : [ {
      "name" : "kids",
      "code" : "02",
      "books" : [ {
        "authors" : [ "Philip Pullman" ],
        "lang" : "en",
        "price" : "699",
        "pub_year" : "1995",
        "title" : "The Golden Compass"
      } ]
    } ],
    "bookstore-phone" : "123",
    "bookstore-emp" : { }
  },
  "test:bookstore2" : {
    "bookstore-name" : "Test"
  }
}



Code Block
collapsetrue
{
  "test:bookstore": {
    "bookstore-name": "Chapters/Easons",
    "categories": [
      {
        "code": "01/1",
        "name": "SciFi",
        "books": [
          {
            "authors": [
              "Iain M. Banks"
            ],
            "lang": "en/it",
            "price": "895",
            "pub_year": "1994",
            "title": "Feersum Endjinn/Endjinn Feersum"
          },
          {
            "authors": [
              "Ursula K. Le Guin"
            ],
            "lang": "en",
            "price": "1099",
            "pub_year": "1999",
            "title": "Far Horizons"
          }
        ]
      },
      {
        "name": "Horror",
        "code": "03",
        "books": [
          {
            "authors": [
              "ABC"
            ],
            "lang": "en",
            "price": "699",
            "pub_year": "1995",
            "title": "Horror Book"
          }
        ]
      }
    ]
  }
}




Note
Note: Open for suggestions for alternative approaches

...