Skip to content

What's the best way to serialize to json a class method? #3943

Answered by nlohmann
johnsturgeon asked this question in Q&A
Discussion options

You must be logged in to vote

See https://json.nlohmann.me/features/arbitrary_types/ - you need to define a to_json function in the same namespace of your class. The macros do not work as they would not be able to serialize total_yards.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@johnsturgeon
Comment options

Answer selected by johnsturgeon
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants