Is this the best way to map the members of a class to keys for multiple objects? #2388
Answered
by
nlohmann
dominique120
asked this question in
Q&A
-
So I have a pretty standard class called Client with its usual members(id, name, etc) and I've succeed in getting it mapped to its keys for each instance of the object and I have the output I want. However I'm not convinced I'm doing it the right way. Is there a better way to do this? This is the code I wrote:
The format I get is as follows and its exactly as I want it:
|
Beta Was this translation helpful? Give feedback.
Answered by
nlohmann
Sep 12, 2020
Replies: 1 comment 1 reply
-
You may want to define a |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
dominique120
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You may want to define a
to_json
function for your typeClient
. See https://github.com/nlohmann/json#arbitrary-types-conversions for more information.