0

How can i compare two Json document's and find the difference between them in Marklogic using javascript?

  • In XPath 3.1 you can use the deep-equal() function, but I don't know for sure whether that works in MarkLogic. Also it doesn't "find the difference", it just tells you whether they are equal. – Michael Kay May 08 '22 at 18:50
  • https://stackoverflow.com/q/8572826/14419 – Mads Hansen May 08 '22 at 21:08

1 Answers1

-1

To compare 2 JSON Objects, you could just use The following function:

const areTheSame = (foo, bar) => JSON.stringify(foo) == JSON.stringify(bar);

// Example:
areTheSame({foo: 'bar'}, {foo: 'bar'}) // true

EDIT: As i mentionned, you cannot find the difference of 2 Objects... Good Luck!

Ramy Hadid
  • 120
  • 6