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 json.Number support to UnmarshalString #2396

Merged
merged 3 commits into from
Sep 28, 2022
Merged

Add json.Number support to UnmarshalString #2396

merged 3 commits into from
Sep 28, 2022

Conversation

Desuuuu
Copy link
Contributor

@Desuuuu Desuuuu commented Sep 28, 2022

UnmarshalString currently supports most basic types (string, int, float64, ...), but not json.Number, which is used when decoding float values from JSON.

This PR:

  • Adds json.Number support to UnmarshalString
  • Implements graphql.UnmarshalString tests which were missing
  • Changes the behaviour of graphql.UnmarshalString with float64 inputs to output a string with the smallest number of digits necessary (graphql.UnmarshalString(float64(123)) will output "123" instead of "123.000000")

The last change while not strictly necessary seemed to make more sense when I was writing the tests. I made it in a separate commit so it can be easily discarded.

I have:

  • Added tests covering the bug / feature (see testing)
  • Updated any relevant documentation (see docs)

@coveralls
Copy link

Coverage Status

Coverage increased (+0.2%) to 75.641% when pulling b14a945 on Desuuuu:unmarshal-string into daa4407 on 99designs:master.

@StevenACoffman StevenACoffman merged commit a9d0603 into 99designs:master Sep 28, 2022
@StevenACoffman
Copy link
Collaborator

Thanks!

@Desuuuu Desuuuu deleted the unmarshal-string branch October 2, 2022 21:27
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.

3 participants