Skip to content

JSONFormatter: check implemented interface before scalars#37

Open
pschultz wants to merge 1 commit intomgutz:masterfrom
classmarkets:bug/custom-scalars
Open

JSONFormatter: check implemented interface before scalars#37
pschultz wants to merge 1 commit intomgutz:masterfrom
classmarkets:bug/custom-scalars

Conversation

@pschultz
Copy link

A type alias for built-in scalar types may implement the fmt.Stringer or json.Marshaler interface. However, the JSONFormatter checked for the scalar type before considering the interfaces, and then used one of the strconv functions to encode the value.

That is a) unexpected and b) doesn't necessarily produce correct JSON, leading to a panic. For instance, strconv.FormatFloat(math.Inf(1), 'g', -1, 64) encodes to +Inf, not "+Inf".

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