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

encoding/json: float output change breaks BigQuery API #20033

Closed
jba opened this issue Apr 18, 2017 · 1 comment

Comments

Projects
None yet
3 participants
@jba
Copy link
Contributor

commented Apr 18, 2017

This isn't a bug in Go, but it does cause breakage elsewhere. I'm not sure what the fix should be (if any).

What version of Go are you using (go version)?

1.7.5, 1.8

What operating system and processor architecture are you using (go env)?

Linux amd64

What did you do?

Ran this program:

package main

import (
    "encoding/json"
    "fmt"
    "log"
)

func main() {
    b, err := json.Marshal(5e20)
    if err != nil {
        log.Fatal(err)
    }
    fmt.Println(string(b))
}

In 1.7.5, the output is 5e+20.

In 1.8, the output is 500000000000000000000.

Both are legal JSON, but the latter breaks BigQuery:

InsertAll googleapi: Error 400: Invalid JSON payload received. Unable to parse number.
[{"json":{"MyFloat":50000000000000000000
                    ^, badRequest

@bradfitz bradfitz changed the title encoding/json float output change breaks BigQuery API encoding/json: float output change breaks BigQuery API Apr 19, 2017

@bradfitz

This comment has been minimized.

Copy link
Member

commented Apr 19, 2017

Seems like a BigQuery bug. That is how Chrome formats it too. We explicitly switched formatting so we'd behave like Node.js & Chrome etc.

In Chrome:
screen shot 2017-04-18 at 5 17 49 pm

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.