Skip to content

std::variant<int, float, bool, std::string> #417

Answered by beached
iwasz asked this question in Q&A
Discussion options

You must be logged in to vote

If this is representative and there is no tag member to dispatch with, then I would look into json_raw and a custom constructor where you can inspect the data.

struct FooConstructor {
std::variant<...> operaetor( )( char const * s, size_t sz ) const {
auto jv = daw:::json::json_value( string_view( s, sz ) );
...
}
};

Then a mapping type like `json_raw<json_value, FooConstructor>`.  

But this is similar to the variant_on_members.cpp example where what members exist are used to determine the type.  But most JSON that has typing like that also has a member to tell the reader of the document what type to interpret it as.  

As for the error, I can double check that later.  Seems like it shou…

Replies: 7 comments 4 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by iwasz
Comment options

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

@beached
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

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

Comment options

You must be logged in to vote
0 replies
Comment options

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

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