-
Notifications
You must be signed in to change notification settings - Fork 61
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
Support automatic conversion between text and binary string representations #476
Support automatic conversion between text and binary string representations #476
Conversation
b06ee3f
to
139da95
Compare
139da95
to
0663f95
Compare
Thanks @benluddy for detailed write up in #449 and this POC! The POC covers all use cases you mentioned and the roundtrip tests illustrating those use cases are great! I see that Since tag numbers 21-23 are defined in Section 3.4.5.2 of RFC 8949, what do you think about moving For example, we can add a decoding mode with 2 options:
This new decoding mode for tags 21-23 would match the new encoding mode It can also help simplify Thoughts? |
Yes, that sounds reasonable. I waffled a bit on the shape of the decode options before ending up with the current iteration. It was clear that the exact text conversion behavior depends on the type of the destination Go value, but less clear whether or not it was useful to make those types configurable. The example in the roundtrip test (string: encode, []byte: decode) is sufficient for my use case. Would you prefer to see the TextConversions function replaced entirely by two decode options: one for decoding into strings and one for byte slices? |
@benluddy Yes, that would be great! 👍 Thanks for suggesting it. |
0663f95
to
6178d1c
Compare
Updated based on the discussion from last month. It should be fairly close to its final shape now. I'll follow up soon to fill out the test coverage. |
e164d09
to
7474624
Compare
OK, I think this is ready now. While I was filling in the test coverage gaps, I realized that only one new decode option was required. The existing option Please take another look! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@benluddy Thanks for updating this PR!
After wrapping up some other PR reviews this weekend, I only had time left to review encoding changes and related tests in this PR.
I left a couple comments, e.g. we should encode tags 21-23 before encoding other user registered tags.
7474624
to
e922c80
Compare
These options improve interoperability with programs that use JSON to encode and decode objects to and from both struct types and empty interface values. Signed-off-by: Ben Luddy <bluddy@redhat.com>
e922c80
to
83e9c2b
Compare
Hi @fxamacker, I've pushed changes to address your feedback on the encode side. Thanks for the review! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@benluddy Thanks for updating this PR and great discussions! LGTM! 👍
Description
This is a proof-of-concept solution for #449. It includes a test that roundtrips a struct value with fields of types
[]byte
and[5]byte
tointerface{}
and back to the original struct type, via both CBOR (using the features here) and via encoding/json.PR Was Proposed and Welcomed in Currently Open Issue
Checklist (for code PR only, ignore for docs PR)
Last line of each commit message should be in this format:
Signed-off-by: Firstname Lastname firstname.lastname@example.com
(see next section).
Certify the Developer's Certificate of Origin 1.1
the Developer Certificate of Origin 1.1.