Skip to content

Indeterministic result ordering for some selectors #10

Description

@tobyink

Migrated from rt.cpan.org #130488 (status was 'open')

Requestors:

From christoph.burgmer@gmail.com on 2019-09-10 21:38:27
:

For the given selectors and documents I can reproduce differently ordered results on re-runs:

Exhibit A

Selector: $[*]
Document:
{
"some": "string",
"int": 42,
"object": {
"key": "value"
},
"array": [0, 1]
}

Outcome #1:
[
42,
[
0,
1
],
"string",
{
"key": "value"
}
]

Outcome #2:
[
{
"key": "value"
},
42,
[
0,
1
],
"string"
]

Exhibit B

Selector: $.store..price
Document:
See https://cburgmer.github.io/json-path-comparison/results/recursive_on_nested_object.html

Outcome #1:
[
19.95,
8.95,
12.99,
8.99,
22.99
]

Outcome #2:
[
8.95,
12.99,
8.99,
22.99,
19.95
]

Expected:

Deterministic ordering to reduce flakiness in output.

Rationale:

This is a blocker for this implementation to be added to the comparison of aforementioned project, see cburgmer/json-path-comparison#4 .

I believe the nondeterminism comes from Perl's hashes not guaranteeing order. It's debatable however whether JSONPath should even guarantee order, see e.g. cburgmer/json-path-comparison#3 .
I'm happy to find other means for now to introduce a deterministic response but am limited by my knowledge of Perl. Happy for pointers. Looked at Tie::IxHash but can't figure out how to bring it in after JSON decoding.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions