Skip to content

Examples

Piotr Kafel edited this page May 21, 2015 · 2 revisions

Flat JSON example

Left JSON

{
  "firstName": "Peter",
  "lastName": "Parker",
  "createdBy": "Stan Lee"
}

Right JSON

{
  "firstName": "Peter",
  "lastName": "Quill",
  "species": "Human/Spartoi"
}

Output

{
  "type": "OBJECT",
  "diff": [
    {
      "key": "createdBy",
      "value": "Stan Lee",
      "op": "ADD",
      "valueType": "SCALAR"
    },
    {
      "key": "firstName",
      "value": "Peter",
      "op": "NONE",
      "valueType": "SCALAR"
    },
    {
      "key": "lastName",
      "value": "Parker",
      "op": "ADD",
      "valueType": "SCALAR"
    },
    {
      "key": "lastName",
      "value": "Quill",
      "op": "REMOVE",
      "valueType": "SCALAR"
    },
    {
      "key": "species",
      "value": "Human/Spartoi",
      "op": "REMOVE",
      "valueType": "SCALAR"
    }
  ]
}

JSON with array example

Left JSON

{
  "nickName": "Spiderman",
  "abilities": [
    "superhuman strength",
    "superhuman agility",
    "ability to cling to most surfaces"
    ]
}

Right JSON

{
  "nickName": "Star Lord",
  "abilities": [
    "superhuman strength",
    "master strategist",
    "problem solver"
    ]
}

Output

{
  "type": "OBJECT",
  "diff": [
    {
      "key": "abilities",
      "value": [
        {
          "key": null,
          "value": "superhuman strength",
          "op": "NONE",
          "valueType": "SCALAR"
        },
        {
          "key": null,
          "value": "superhuman agility",
          "op": "ADD",
          "valueType": "SCALAR"
        },
        {
          "key": null,
          "value": "master strategist",
          "op": "REMOVE",
          "valueType": "SCALAR"
        },
        {
          "key": null,
          "value": "ability to cling to most surfaces",
          "op": "ADD",
          "valueType": "SCALAR"
        },
        {
          "key": null,
          "value": "problem solver",
          "op": "REMOVE",
          "valueType": "SCALAR"
        }
      ],
      "op": "NONE",
      "valueType": "ARRAY"
    },
    {
      "key": "nickName",
      "value": "Spiderman",
      "op": "ADD",
      "valueType": "SCALAR"
    },
    {
      "key": "nickName",
      "value": "Star Lord",
      "op": "REMOVE",
      "valueType": "SCALAR"
    }
  ]
}

Clone this wiki locally