Skip to content

JSON v3 — Field v3 Migration + Post-Decode Validation#8

Merged
cdvelop merged 2 commits intomainfrom
jules-9782617429973433732-7df7943c
Mar 26, 2026
Merged

JSON v3 — Field v3 Migration + Post-Decode Validation#8
cdvelop merged 2 commits intomainfrom
jules-9782617429973433732-7df7943c

Conversation

@cdvelop
Copy link
Collaborator

@cdvelop cdvelop commented Mar 23, 2026

I have completed the Field v3 migration for the tinywasm/json package.

Key Changes:

  1. Simplified Key Mapping: Removed parseJSONTag logic. The library now uses field.Name directly as the JSON key for both encoding and decoding.
  2. First-class OmitEmpty Support: Replaced ,omitempty string tag parsing with the boolean field.OmitEmpty property from fmt.Field.
  3. Post-Decode Validation: The Decode function now checks if the target fmt.Fielder implements the fmt.Validator interface and calls Validate() after parsing.
  4. DecodeRaw Addition: Introduced DecodeRaw for scenarios where post-decode validation should be skipped.
  5. Documentation Updates: Updated the README.md to reflect the new behavior and API changes.
  6. Test Suite Overhaul: Updated the entire test suite to align with the new schema-first approach and added new tests for validation and DecodeRaw.

All tests in the tests/ directory passed successfully.


PR created automatically by Jules for task 9782617429973433732 started by @cdvelop

…t-decode Validate()

This commit implements the Field v3 migration as described in docs/PLAN.md:
- Updated `encode.go`: removed `parseJSONTag`, updated `encodeFielder` to use `field.Name` and `field.OmitEmpty`.
- Updated `parser.go`: modified `matchFieldIndex` to use `field.Name` directly.
- Updated `decode.go`: implemented `DecodeRaw` and updated `Decode` to include post-decode validation using `fmt.Validator`.
- Updated all test files: removed `JSON` field literals, updated expectations, and added validation tests in `tests/validation_test.go`.
- Updated `README.md` to reflect new API and behavior.

Co-authored-by: cdvelop <44058491+cdvelop@users.noreply.github.com>
@google-labs-jules
Copy link
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@cdvelop cdvelop merged commit d96ac5a into main Mar 26, 2026
@cdvelop cdvelop deleted the jules-9782617429973433732-7df7943c branch March 26, 2026 13:42
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