Read/write of std::chrono data #1606
Replies: 4 comments 1 reply
|
I've been wanting to add If you could provide some examples of |
|
For using namespace std::chrono;
std::chrono::year_month_day ymd{2025y, std::chrono::March, 4d};translates to {"year":2025,"month":3,"day":4}For std::chrono::system_clock::time_point tp = std::chrono::system_clock::now();might translate to {"unit":"microseconds","count":1739234225419488}It would be nice to have |
|
I am also interested in this feature |
|
@Nathan-M-code what do you use from std::chrono, and what would you expect the JSON to look like? How much configuration to the format should there be? I'm just trying to figure out how to approach a robust implementation of std::chrono. |
Uh oh!
There was an error while loading. Please reload this page.
I'm using Glaze on a C++23 project to add JSON import/export of existing data structures.
Where the data structures use "normal" types, things work well. However I'm struggling to use Glaze to serialise/deserialise classes which have
std::chronomembers. I'm quite new to Glaze.For example, one data structure is a
std::vectorof a type which has astd::chrono::year_month_daymember as well as astd::chrono::system_clock::time_pointmember. I have tried to use custom reader/writer code with lambdas but I can't get it to compile.I think part of the problem is that
std::chrono::year_month_dayhas getters but no setters; I would need to create a new instance. I could replacestd::chrono::year_month_daywith a custom struct which does basically the same thing, but I am reluctant to change the current data definitions.Has anyone got any snippet of code that uses Glaze to read/write
std::chronodata? I'm not able to find any examples so far.All reactions