Comments (3)
Hello, thank you for the kind words.
null.Float
/zero.Float
and would be the closest thing to Javascript numbers, and should support scientific notation.
Just making sure: are you numbers within the range of Go's int64 and just happen to be in scientific notation, or are your numbers larger than int64 can handle?
Go's encoding/json
package dislikes scientific notation in any integer, even if it's a small number: http://play.golang.org/p/u_Am5XoPJW
Seems like a bug to me, to be honest...
Did you add support for something like big.Int
?
Either way, I would be happy to include your code.
from null.
Hi guregu,
So upon further investigation, it seems that my issue stemmed from first unmarshalling the json to a map[string]interface{}, which automatically writes numbers in scientific notation. Sorry about that. The solution I wrote was basically, if unmarshalling to an int64 failed, then try unmarshalling it to a float64, and using that number if it's a valid int64 (I check that it doesn't have decimals, and is within the int64 range). If you're still interested, I'll be happy to supply you the small fix (it's only 10 lines). Thank you for your time, and have a nice day!
from null.
I'll keep things as-is for now, but thanks for the input.
from null.
Related Issues (20)
- Bad marshaling implementation on null.Time struct
- Why does null.Time text-marshaling return null string? HOT 3
- Release v4 HOT 2
- Request parsing for null.Time HOT 1
- null.String composite literal uses unkeyed fields HOT 2
- error undefined: sql.NullTime HOT 1
- Storing null values using this library in database HOT 3
- Strings.StringFrom() passes Valid as true even if the string is empty HOT 3
- how versions are working HOT 1
- undefined: sql.NullTime HOT 1
- Bug on undefined type HOT 1
- [Question] Is it possible to have SQL null values treated as null in Go but encode them to zero in JSON? HOT 2
- Not to use sql.Null*** for storing value? HOT 1
- Issue with omitempty HOT 4
- Not to use fmt.Errorf for UnmarshalJSON error HOT 6
- Generics support HOT 7
- how use json null set sql time field to null? HOT 3
- uint64 support HOT 2
- field: models.SysUserBean.Username, unsupport field type &{{ %!s(bool=false)}}, may be miss setting tag
- I am getting following error when importing this package HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from null.