This repository was archived by the owner on Apr 1, 2025. It is now read-only.
Add support for json.Number.#414
Merged
niemeyer merged 2 commits intogo-yaml:v2from Nov 15, 2018
Merged
Conversation
This commit adds support for encoding json.Number as a number
instead of as a string, which is the underlying type of
json.Number.
Care has been taken to not introduce a dependency on the
encoding/json package, by using an interface that specifies the
methods of json.Number instead of the datatype itself. This also
means that other packages that use a similar datatype will be
supported. (Like json-iterator)
This is useful for tools that wish to convert JSON data into YAML
data by deserializing JSON into a map[string]interface{}, and use
the json.Encoder's UseNumber() method, or structs that use the
json.Number datatype and also wish to support yaml.
Author
|
I based this work on v2, since it's the version I'm using, but I'm happy to base it on the devel branch if that would be more appropriate. |
Contributor
|
Thanks! |
Author
|
Thank you! |
This was referenced Dec 14, 2021
mihaitodor
added a commit
to mihaitodor/yaml
that referenced
this pull request
Sep 21, 2022
This is a port of go-yaml#414 to the v3 branch. Fixes go-yaml#807.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This commit adds support for encoding json.Number as a number
instead of as a string, which is the underlying type of
json.Number.
Care has been taken to not introduce a dependency on the
encoding/json package, by using an interface that specifies the
methods of json.Number instead of the datatype itself. This also
means that other packages that use a similar datatype will be
supported. (Like json-iterator)
This is useful for tools that wish to convert JSON data into YAML
data by deserializing JSON into a map[string]interface{}, and use
the json.Encoder's UseNumber() method, or structs that use the
json.Number datatype and also wish to support yaml.