Deserializing third party types from array #4220
Replies: 1 comment 1 reply
-
Can you please provide example code? |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am working with
glm
and so want to be able to deserialize things likeglm::vec3
. The way the documentation suggests would be something likeHowever, to reduce boiler plate, I would like the following instead:
I have defined my appropriate
from_json
function but I now run into an error when runningjson::parse(file)
. The error is about a size mismatch between vec3s.I assume that the parser is trying to interpret things as vec3s that shouldn't be interpreted as vec3s due to my form being more lenient than the suggested form. What I want is for
json::parse
to work in the "vanilla" way but then to be able to use myfrom_json
function for extracting vec3s from specific places in the JSON later on. In particular, I use a lot ofstd::vector<glm::vec3>
so would like to be able to deserialize these easily and without boilerplate.What should I do here? Is there a way of doing this or is what I'm trying just a bad idea?
Beta Was this translation helpful? Give feedback.
All reactions