Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should we provide for structured types in containable? #127

Open
cabo opened this issue Oct 25, 2021 · 5 comments
Open

Should we provide for structured types in containable? #127

cabo opened this issue Oct 25, 2021 · 5 comments

Comments

@cabo
Copy link
Member

cabo commented Oct 25, 2021

#125 (comment)

@goessner
Copy link
Collaborator

goessner commented Nov 2, 2021

After thinking a while about comparing structured types, I now see no problem to support equality of them. I agree to handling them is straightforward:

Two structured types are equal, if they are equal on a per-node basis.

also see The Abstract Equality Comparison Algorithm ... not exactly, what we want though.

We need to be clear about order ... !

[1,2] == [1,2]
{x:1,y:2} == {x:1,y:2}
[1,2] == [2,1]  // ?
{x:1,y:2} == {y:2,x:1} // ?
[] == []
{} == {}

Containables may be defined on exactly that comparison rule.

I believe, we need to add objects here again. Also we need to discuss subsets.

Array Examples:

1 in [1,2,3]             // primitive value lhs
[1,2] in [1,2,3]         // structured value lhs
[1,2] in [1,2,3,[1,2]] // subset
[] in [1,2,3]             // empty array
[] in [1,2,3,[]]          // empty array
{} in [1,2,3,{}]          // empty object
{x:1,y:2} in [{x:1,y:2}]

Object Examples:

'x' in {x:1,y:2}
['x','y'] in {x:1,y:2}
{x:1} in {x:1,y:2}
{z:3,x:1} in {x:1,y:2,z:3}
{} in  {x:1,y:2}

Once having agreement about handling that edge cases (maybe there are more), we might add it to the spec.

Btw.: JavaScript resolves all comparisons above to false, since objects are equal only, if they are referencing the same object (no deep equals).

@glyn
Copy link
Collaborator

glyn commented Nov 3, 2021 via email

@goessner
Copy link
Collaborator

goessner commented Nov 3, 2021

I totally support a decision to:

  • not dealing with subsets
  • restrict the rhs to arrays only

with contain-expr's.

@cabo
Copy link
Member Author

cabo commented Jan 17, 2022

We decided not to have " in ", so this is now closed/revisit-after-base-done.

@cabo cabo closed this as completed Jan 17, 2022
@cabo cabo mentioned this issue Jan 24, 2022
@glyn glyn reopened this Dec 20, 2023
@gregsdennis
Copy link
Collaborator

I've supported this with configuration. You can play with it at https://json-everything.net/json-path.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants