Skip to content

Preserve boolean distinctions in nested JSON equality - #372

Open
oyeong011 wants to merge 2 commits into
jmespath:developfrom
oyeong011:fix/nested-json-equality
Open

Preserve boolean distinctions in nested JSON equality#372
oyeong011 wants to merge 2 commits into
jmespath:developfrom
oyeong011:fix/nested-json-equality

Conversation

@oyeong011

Copy link
Copy Markdown

Nested equality currently delegates to Python container equality, so [true] == [1] returns true even though the corresponding JMESPath scalar comparison is false. This also includes incorrect records in filters on nested values.

Compare array elements and object values with an explicit work stack and JMESPath scalar equality. This preserves boolean/number distinctions without adding Python recursion frames. Numeric equality, object key ordering, differing lengths/keys, empty containers, and identical-object fast paths remain supported.

Validation on macOS/Python 3.12.13:

  • Original implementation fails the two new nested comparison/filter regressions.
  • python -m pytest tests -q: 995 passed, 1 skipped.
  • Independently parsed depth-600 JSON arrays and objects pass equality, boolean/number mismatch, unequal-value, and leaf-shape checks without changing the recursion limit.
  • Public API filtering selects numeric records and excludes the corresponding boolean record.

The full platform/Python-version matrix was not run locally. The work stack uses memory proportional to queued structural pairs.

AI disclosure: OpenAI Codex assisted with the implementation, tests, and description. The reported checks were executed locally.

Nested lists and objects must compare their values using JMESPath equality instead of Python numeric coercion.

Confidence: high
Scope-risk: narrow
Tested: 994 tests passed; nested-filter public API QA
Not-tested: Python versions outside 3.12
Use an explicit work stack so separately parsed deeply nested JSON remains comparable while preserving boolean and number distinctions.

Confidence: high
Scope-risk: narrow
Tested: 995 tests passed; depth-600 array/object API QA
Not-tested: Python versions outside 3.12; non-JSON cycles
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant