Skip to content

When reading a json field, is the "get<T>()" needed? #2416

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

You must be logged in to vote

operator[] returns references of type json. So message in auto message = json["details"] is json, but in auto message = json["details"].get<std::string>(); is std::string.

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@tawmoto
Comment options

@nlohmann
Comment options

Answer selected by nlohmann
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