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

Special case JSONPB instances for Google.Protobuf.Wrappers #103

Open
themattchan opened this issue May 21, 2019 · 2 comments
Open

Special case JSONPB instances for Google.Protobuf.Wrappers #103

themattchan opened this issue May 21, 2019 · 2 comments

Comments

@themattchan
Copy link
Collaborator

(From @j6carey)

The proto3 specification says:

"Wrappers use the same representation in JSON as the wrapped primitive type, except that null is allowed and preserved during data conversion and transfer."

and gives these examples:

2, "2", "foo", true, "true", null, 0, …

However, our Haskell implementation does not yet provide such special cases:

HsJSONPB Google.Protobuf.Wrappers> HsJSONPB.toJSONPB (Just (BoolValue True)) HsJSONPB.defaultOptions
Object (fromList [("value",Bool True)])

In order to match the specification, the result should be just Bool True.

Though we could provide Google.Protobuf.Wrappers precompiled in our library,
it might be simpler to special case the code generator to spot the wrapper types
and emit custom code for their JSON-related instances.

@TristanCacqueray
Copy link
Contributor

There is a similar issue with Google.Protobuf.Timestamp where the json encoding is based on the rfc3339 string format. For what it worth, here is a patch for the generated code: change-metrics/monocle@d29f2b8#diff-e1074028e244819fddeeb7e6ed1318ffd6a41ec81e53de174752f38ceb017eaa .

Would it be possible to add such module directly to proto3-suite, or should we create a new proto3-suite-google package?

@Gabriella439
Copy link
Contributor

@TristanCacqueray: I think it would be fine to add support for those standard types in proto3-suite

TristanCacqueray added a commit to TristanCacqueray/proto3-suite that referenced this issue May 7, 2021
This change adds a new Google.Protobuf.Timestamp module to
handle the custom RFC3339 encoding used for JSON.

Related awakesecurity#103
Gabriella439 pushed a commit that referenced this issue May 7, 2021
This change adds a new Google.Protobuf.Timestamp module to
handle the custom RFC3339 encoding used for JSON.

Related #103
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

No branches or pull requests

3 participants