Skip to content

fix: preserve json values and evaluate array filter paths correctly - #31

Open
rupayon123 wants to merge 5 commits into
kavix:mainfrom
rupayon123:contribution/json-filter-correctness-20260909
Open

rupayon123 wants to merge 5 commits into
kavix:mainfrom
rupayon123:contribution/json-filter-correctness-20260909

Conversation

@rupayon123

Copy link
Copy Markdown
Contributor

JSON filtering currently corrupts large numeric IDs, rejects documented .users[].name projections, turns empty arrays into null, and mishandles consecutive or malformed array brackets (including a panic for .items][0]).

This PR fixes those independent defects in four commits:

  • Preserve JSON number literals during decoding, including integers above 2^53 and large exponents, while still rejecting trailing JSON values.
  • Apply the remaining path to each projected element, preserving array-valued fields and supporting nested projections.
  • Keep empty filtered/flattened arrays as [].
  • Parse every consecutive bracket suffix and return errors for malformed brackets instead of ignoring suffixes or panicking.

Regression tests reproduce each defect before its fix. Validation: env -u NO_COLOR go test ./..., go vet ./internal/filter, and git diff --check pass with Go 1.27.1 on macOS. NO_COLOR is unset for the suite because existing printer tests explicitly expect ANSI output.

No new dependencies. Prepared with AI assistance; tests were run locally.

@rupayon123

Copy link
Copy Markdown
Contributor Author

Additional fixes pushed to this branch:

  • a5e5e75: Support JSON-quoted field names containing dots, brackets, escapes and empty names.

Full Go tests, go vet and build pass. The added quoted-field cases cover dotted/bracketed names, escaped quotes, Unicode escapes, empty names, projections and malformed syntax. Today's changes have no new findings under golangci-lint v2.13.2 using a migrated copy of the repository configuration. This is a scoped lint result: a full CLI-branch scan still reports 93 findings outside today's changes; the legacy v1 linter cannot read the installed Go 1.27 export format.

Prepared with AI assistance. Changes are submitted for review; this is not a claim of maintainer approval.

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