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

CBOR Research #342

Closed
vinniefalco opened this issue Sep 15, 2020 · 5 comments
Closed

CBOR Research #342

vinniefalco opened this issue Sep 15, 2020 · 5 comments
Assignees

Comments

@vinniefalco
Copy link
Member

We need preliminary research into CBOR. Is the mapping to and from a json::value clean? Are there any obstacles to implementing a parser and serializer for CBOR? This is research-only, no implementation.

@vinniefalco
Copy link
Member Author

https://cbor.io/spec.html

There are extensible "tags", which might not map: https://www.iana.org/assignments/cbor-tags/cbor-tags.xhtml

@rainerdeyke
Copy link

A CBOR implementation is not expected to know all semantic tags (and generally cannot, since new semantic tags can be added at any time). It is perfectly valid to ignore all semantic tags completely, and this is explicitly stated in the CBOR spec. Section 2.4, paragraph 3: "Understanding the semantic tags is optional for a decoder; it can just jump over the initial bytes of the tag and interpret the tagged data item itself." This seems like the best approach for Boost.JSON, since none of the types used by JSON require semantic tags.

@vinniefalco
Copy link
Member Author

The one interesting decision that needs to be made here is how to handle CBOR byte strings (major type 3), as they aren't representable in JSON or in the current boost::json::value.

@vinniefalco
Copy link
Member Author

Well Peter did this

@ecorm
Copy link

ecorm commented Apr 22, 2024

A CBOR implementation is not expected to know all semantic tags (and generally cannot, since new semantic tags can be added at any time). It is perfectly valid to ignore all semantic tags completely, and this is explicitly stated in the CBOR spec. Section 2.4, paragraph 3: "Understanding the semantic tags is optional for a decoder; it can just jump over the initial bytes of the tag and interpret the tagged data item itself." This seems like the best approach for Boost.JSON, since none of the types used by JSON require semantic tags.

Sorry for the late comment. There are a number of CBOR tags where it's impossible to reconstitute the value without knowing the tag. For example, tags 2 (unsigned bignum) and 3 (negative bignum). I've pointed out this flaw years ago on the CBOR mailing list, yet new tags keep popping up where part of the information (beyond semantics) is encoded in the tag. They are too obsessed over saving every possible byte, and don't seem care about being able to transcode to JSON without losing unrecoverable information.

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

4 participants