Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jsonpb: fix unmarshaling JSON object with escaped string into Struct type #612

Merged
merged 2 commits into from
May 18, 2018
Merged

Conversation

cybrcodr
Copy link
Contributor

Fix unmarshaling JSON object with escaped string into Struct type.

Fixes #605

@cybrcodr cybrcodr requested a review from dsnet May 18, 2018 02:42
{"StructValue containing StringValue's", Unmarshaler{}, "{\"escaped\": \"a\\/b\", \"unicode\": \"\\u00004E16\\u0000754C\"}",
&stpb.Struct{
Fields: map[string]*stpb.Value{
"escaped": {Kind: &stpb.Value_StringValue{"a/b"}},
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This testcase exposes issue #605.

Note that the other testcases that I added here are somehow working even before adding the fix in.

Copy link
Contributor Author

@cybrcodr cybrcodr left a comment

Choose a reason for hiding this comment

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

Minor update. Just thought that raw strings for the JSON are easier to read.

@cybrcodr cybrcodr merged commit 70c277a into golang:master May 18, 2018
@golang golang locked and limited conversation to collaborators Jun 26, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

jsonpb: Attempting to unmarshal escaped JSON into a protobuf throws an error
2 participants