getml / reflect-cpp

A C++20 library for fast serialization, deserialization and validation using reflection. Supports JSON, BSON, CBOR, flexbuffers, msgpack, TOML, XML, YAML / msgpack.org[C++20]
https://getml.github.io/reflect-cpp/
MIT License
783 stars 63 forks source link

Json int64_t Support ? #101

Closed BestITUserEUW closed 1 month ago

BestITUserEUW commented 1 month ago

Hey,

I have a struct that i want to write and read which contains a timestamp in milliseconds of type int64_t. After parse i get: "timestamp":-2125153807 Which is integer overflow. Is it possible to support int64_t ?

P.S. I can't use rfl::Timestamp, timestamp has to be sent as number.

liuzicheng1987 commented 1 month ago

@BestITUserEUW , you seem to have found a solution to this.

If you have, feel free to open a PR.

liuzicheng1987 commented 1 month ago

A fix would basically involve minor edits in these two files:

https://github.com/getml/reflect-cpp/blob/main/include/rfl/json/Reader.hpp

https://github.com/getml/reflect-cpp/blob/main/include/rfl/json/Writer.hpp

BestITUserEUW commented 1 month ago

There is already a fix from #92 works now. I used v0.10.0 i'll just use main branch until it get's into a new release.

liuzicheng1987 commented 1 month ago

Yes, of course...I forgot that that was after v0.10.0. I'll do the formal release for v0.11.0 soon.