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

Add Encoder/Decoder types #192

Merged
merged 1 commit into from
Oct 24, 2017
Merged

Conversation

robertgzr
Copy link
Contributor

Usage is similar to the stdlibs JSON encoder/decoder but I tried to
leave the general structure of the code the same.

Main motivation was to support encoding/decoding options to allow
encoding string-type map keys as quoted TOML keys.
This was implemented on the Encoder with QuoteMapKeys(bool).

The TOML spec supports using UTF-8 strings as keys.
https://github.com/toml-lang/toml/blob/master/versions/en/toml-v0.4.0.md#table

Replaces #190

@robertgzr
Copy link
Contributor Author

@pelletier @moorereason feedback?

Copy link
Owner

@pelletier pelletier left a comment

Choose a reason for hiding this comment

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

This looks good! Not sure how I feel about the file name stream.go though. I'd just put them in marshal.go.

@robertgzr
Copy link
Contributor Author

robertgzr commented Oct 23, 2017

I moved the new types into marshal.go as suggested. Makes sense as they are now defined where we use them...
Additionally I embedded the options in the encoder/decoder types which makes accessing them nicer.

I also made sure the package global Unmarshal uses the defaults.

@robertgzr
Copy link
Contributor Author

I will squash once you approve 🙂

@pelletier
Copy link
Owner

@robertgzr Seems like you have some conflicts :) Don't worry about squashing, I always squash and merge.

@robertgzr
Copy link
Contributor Author

robertgzr commented Oct 23, 2017

@pelletier I just wanted to make it easier to look at individual commits but it seems Github doesn't like the first one that deletes stream.go :P
I will just force rebase if you don't mind

@pelletier
Copy link
Owner

Go for it!

Usage is similar to the stdlibs JSON encoder/decoder but I tried to
leave the general structure of the code the same.

Main motivation was to support encoding/decoding options to allow
encoding string-type map keys as quoted TOML keys.
This was implemented on the Encoder with QuoteMapKeys(bool).

> The TOML spec supports using UTF-8 strings as keys.
> https://github.com/toml-lang/toml/blob/master/versions/en/toml-v0.4.0.md#table
@pelletier pelletier merged commit 4e9e0ee into pelletier:master Oct 24, 2017
@pelletier
Copy link
Owner

Thank you very much for that contribution @robertgzr!

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

Successfully merging this pull request may close these issues.

2 participants