Skip to content

fix: [CN-69] respect struct json tags in JSON encoder with UseJSONTagName enabled#66

Merged
vpakhuchyi merged 1 commit intomainfrom
CN-69-use-json-tag-name-config-option-is-ignored
Nov 13, 2025
Merged

fix: [CN-69] respect struct json tags in JSON encoder with UseJSONTagName enabled#66
vpakhuchyi merged 1 commit intomainfrom
CN-69-use-json-tag-name-config-option-is-ignored

Conversation

@vpakhuchyi
Copy link
Owner

Pull request

Link to the related ticket

https://censor.atlassian.net/browse/CN-69

Description of changes

When UseJSONTagName configuration option is enabled JSON encoder shall use json structure tags instead of field names.

Checklist

Please ensure that your pull request complies with the following requirements:

  • The changes have been tested locally (if applicable).
  • The documentation has been updated (if applicable).

Copilot AI review requested due to automatic review settings November 13, 2025 09:34
@vpakhuchyi vpakhuchyi changed the title fix: [CN-69] respect struct json tags in JSON encoder with UseJSONTag… fix: [CN-69] respect struct json tags in JSON encoder with UseJSONTagName enabled Nov 13, 2025
@vpakhuchyi vpakhuchyi merged commit 2166a75 into main Nov 13, 2025
10 checks passed
@vpakhuchyi vpakhuchyi deleted the CN-69-use-json-tag-name-config-option-is-ignored branch November 13, 2025 09:36
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements support for the UseJSONTagName configuration option in the JSON encoder, allowing struct fields to use their json tag names instead of Go field names when encoding.

  • Adds logic to parse and respect json struct tags in the JSON encoder
  • Implements proper handling of tag options, dash tags (json:"-"), and fallback to field names
  • Updates documentation to clearly explain the feature behavior

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
internal/encoder/json_encoder.go Implements JSON tag parsing logic in getStructFields method, adds UseJSONTagName configuration to encoder initialization, includes gocognit suppression for increased complexity
internal/encoder/json_encoder_test.go Adds comprehensive test coverage for UseJSONTagName feature with multiple edge cases including aliased tags, skipped fields, empty tag names, and default behavior
docs/index.md Updates configuration documentation to accurately describe the UseJSONTagName option behavior, clarifying how it mirrors Go's encoding/json package

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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