Code Monkey home page Code Monkey logo

Comments (4)

clagraff avatar clagraff commented on August 11, 2024

Hi. It's been a while since I looked at the repo. But I did take a quick peak at the code, and it seems like when comparing two array values, it goes index by index. So the order would matter.

In your example for the first element in SelectedData, the s1 object where {"ID": 5 ...} would be compared to s2's {"ID"; 1 ...} which obviously wouldn't match up.

So while the unordered contents of SelectedData is the same between s1 and s2, here the order matters.

from json-patch.

clagraff avatar clagraff commented on August 11, 2024

Hi again! I noticed that your example JSON is actually malformed.

You have:

"SelectedData":[{"ID": 5, "bla": "hello5"},{"ID": 1, "bla": "hello1"},{"ID": 2, "bla": "hello2"}]

but I would expect it was actually meant to be:

{"SelectedData":[{"ID": 5, "bla": "hello5"},{"ID": 1, "bla": "hello1"},{"ID": 2, "bla": "hello2"}]}

Note the missing braces at the start and end.

In the event that you call jsonpatch.Equal with something that isnt really json, it does a byte comparison. In which case your two strings (not objects) are entirely different.

That said, even if it were fixed, the ordering of objects in an array would still matter, and so s1 and s2 would still be considered unequal.

from json-patch.

clagraff avatar clagraff commented on August 11, 2024

Does that help at all?

from json-patch.

evanphx avatar evanphx commented on August 11, 2024

@clagraff Thanks for answering the question, yes, it's strict in order.

from json-patch.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.