Skip to content

Update docs for TimeMode, Tag, RawTag, and add example for Embedded JSON Tag for CBOR#659

Merged
fxamacker merged 3 commits intomasterfrom
fxamacker/update-comments-and-docs
Apr 27, 2025
Merged

Update docs for TimeMode, Tag, RawTag, and add example for Embedded JSON Tag for CBOR#659
fxamacker merged 3 commits intomasterfrom
fxamacker/update-comments-and-docs

Conversation

@fxamacker
Copy link
Copy Markdown
Owner

@fxamacker fxamacker commented Apr 26, 2025

Related to #657 #656

This PR updates some comments and adds a requested example. The example shows how to user apps can use almost any current or future CBOR tag number by implementing cbor.Marshaler and cbor.Unmarshaler interfaces.

Essentially, MarshalCBOR and UnmarshalCBOR implemented by user apps are automatically called by this CBOR codec's Marshal, Unmarshal, etc.

The example encodes and decodes a tagged CBOR data item with tag number 262 and the tag content is a JSON object that is "embedded" as a CBOR byte string (major type 2).

Note

RFC 8949 does not mention CBOR tag number 262. IANA assigned CBOR tag number 262 to "Embedded JSON Object" and references the document Embedded JSON Tag for CBOR.

Changes:

  • Update comments/docs for cbor.TimeMode options.
  • Update comments/docs for cbor.Tag and cbor.RawTag.
  • Add a requested example for using Embedded JSON Tag for CBOR (CBOR tag 262).
    • See file: example_embedded_json_tag_for_cbor_test.go

Thanks for your patience. 🙏

Clarify the comments describing cbor.Tag and cbor.RawTag.
@fxamacker fxamacker added the docs label Apr 26, 2025
@fxamacker fxamacker self-assigned this Apr 26, 2025
Mention that:
- time encoding options provided by cbor.TimeMode comply with RFC 8949.
- user apps that prefer to encode time in other ways (e.g. not specified by RFC 8949) can use a CBOR tag number not assigned by IANA and implement cbor.Marshal and cbor.Unmarshal interfaces.

Also, update the comments for each time encoding option to be more useful to programmers who did not read RFC 8949.  The old comments were meant to be stop-gaps due to schedule.
@fxamacker fxamacker force-pushed the fxamacker/update-comments-and-docs branch from 9ed18b9 to df7db22 Compare April 26, 2025 20:34
@fxamacker fxamacker changed the title WIP: Update comments and docs Update docs and add example for Embedded JSON Tag for CBOR Apr 26, 2025
Copy link
Copy Markdown
Contributor

@x448 x448 left a comment

Choose a reason for hiding this comment

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

👍 👍

@fxamacker fxamacker force-pushed the fxamacker/update-comments-and-docs branch from 36287cc to 1c154a2 Compare April 27, 2025 13:16
Copy link
Copy Markdown
Owner Author

@fxamacker fxamacker left a comment

Choose a reason for hiding this comment

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

Thanks for reviewing!

BTW, I changed "content" to "value" in my last commit (no other changes):

preserves the 64-bit floating point content value.

Before merging this, I want to update my comments in the Embedded JSON example today (April 27) but I need to be AFK for a while.

@fxamacker fxamacker force-pushed the fxamacker/update-comments-and-docs branch from 1c154a2 to 92f7b97 Compare April 27, 2025 22:38
@fxamacker fxamacker changed the title Update docs and add example for Embedded JSON Tag for CBOR Update docs for TimeMode, Tag, RawTag, and add example for Embedded JSON Tag for CBOR Apr 27, 2025
@fxamacker fxamacker merged commit 2779884 into master Apr 27, 2025
22 checks passed
@fxamacker fxamacker added this to the v2.9.0 milestone Jul 5, 2025
@fxamacker fxamacker deleted the fxamacker/update-comments-and-docs branch September 16, 2025 02:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants