stephenberry / glaze

Extremely fast, in memory, JSON and interface library for modern C++
MIT License
1.23k stars 123 forks source link

assign intergers to generic-json glz::json_t #1422

Closed alan0526 closed 2 weeks ago

alan0526 commented 2 weeks ago

// code of glz::json_t val_t difinition using val_t = std::variant<null_t, double, std::string, bool, array_t, object_t>; The val_t type of glz::json_t is a variant and there is not an interger in it. And the assignment operator json_t& operator=(const intgers value) is also not exist. So It is not allowed to assign integers to glz::json_t object.

stephenberry commented 2 weeks ago

Thanks for the suggestion. I've been moving towards adding an int64_t to the variant so that we can store either an integer or a double, but doubles can exactly represent most integers, so in the short term converting the integer to a double should be a workable solution. I'll add an assignment operator for integers.

alan0526 commented 2 weeks ago

OK, thanks.

stephenberry commented 2 weeks ago

Support for assigning integers to a glz::json_t has been added in #1425