|
I have the following json: {
"coordinates": [
[57.0069969, 9.8778229],
[57.0069945, 9.8777813],
[57.0069921, 9.8777397],
[57.0070376, 9.8777308]
]
}which I want to read in as struct Coordinate {
double longitude;
double latitude;
};
using Coordinates = std::vector<Coordinate>;Is there any way to do this? |
Answered by
mtygesen
Mar 10, 2025
Replies: 1 comment 1 reply
|
Managed to get it working with the following code template <>
struct glz::meta<Coordinate> {
using T = Coordinate;
constexpr static auto value = glz::array(&T::longitude, &T::latitude);
};
template <>
struct glz::meta<Environment> {
using T = Environment;
constexpr static auto value =
glz::object("coordinates", &T::coordinates);
};
|
1 reply
Answer selected by
mtygesen
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Managed to get it working with the following code