Skip to content

feat: handle json_name in protos#38

Open
hishamank wants to merge 1 commit into
dpup:mainfrom
anghami:json_name
Open

feat: handle json_name in protos#38
hishamank wants to merge 1 commit into
dpup:mainfrom
anghami:json_name

Conversation

@hishamank
Copy link
Copy Markdown

No description provided.

Copy link
Copy Markdown
Owner

@dpup dpup left a comment

Choose a reason for hiding this comment

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

Only 6 months late in reviewing this. Not sure why I didn't see it.

I think we need to document and test the interaction between use_proto_names and use_json_name.

Comment thread README.md

### `use_json_name` (Default: False)

Uses the `json_name` field option instead of the default field name when serializing messages to JSON.
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Suggested change
Uses the `json_name` field option instead of the default field name when serializing messages to JSON.
When true, uses the `json_name` field option from proto definitions for JSON serialization, if available. This allows you to specify custom field names in JSON that differ from the default behavior. Example:
```protobuf
message User {
string user_id = 1 [json_name = "id"]; // Will use "id" in JSON
}

Comment thread data/message.go
// Message has been marked as deprecated
IsDeprecated bool
// JsonName is the json_name option from the proto field, if set.
JsonName string
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Shouldn't this be on data.Field?

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.

2 participants