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

Parse decimals ending in .0 as floats instead of ints #44

Open
ChimeraCoder opened this issue Nov 7, 2016 · 0 comments
Open

Parse decimals ending in .0 as floats instead of ints #44

ChimeraCoder opened this issue Nov 7, 2016 · 0 comments

Comments

@ChimeraCoder
Copy link
Owner

{
    "value": 10.0,
    "timestamp": 147847894,
}

value should be parsed as a float64, but timestamp should be an int64.

This comes from @nstogner: (#22 (comment))

To elaborate on my personal use-case: I would like to be able to define a struct's default values via a JSON object... To do this I would like to use gojson to first create the struct and then use another process to read in the object again to determine the default values, ie:

{ "name": "", "health": "100", "score": 0.0 }
-- piped thru gojson -->

type Foo struct {
Name string `json:"name"`
Health int `json:"health"` 
Score float64 `json:"score"` 
}

-- JSON object piped thru extra process -->

f := Foo{
Health: 100,
}

In other words, I would need to be able to support 0.0 values which get translated into floats.

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

No branches or pull requests

1 participant