Skip to content

Get value without explicit typecasting #1395

@mprat

Description

@mprat

I was wondering if there was a way to get the underlying value of an object without explicit typecasting. Here is what I mean:

json j = R"({"int_type": 3})"_json;

auto i_what_is_this = j["int_type"];

// to get an int, I need to explicitly typecast
auto i_int = j["int_type"].get<int>();

JSON natively supports different types, so is there a way to use that underling type to get auto i = j["int_type"]; to be of type int without explicitly typecasting?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions