Skip to content

How can I use std::string_view as the json_key to "operator []" ? #1529

Closed
@jencoldeng

Description

@jencoldeng

//as follow, this will fail as the key_type pof map is std::string_view
std::map<string_view, bool> mv{{"111",true}, {"222", false}, {"333", true}};
nlohmann::json j4{mv};

//another: fail again, the std::string_view is the json_key
nlohmann::json j5;
std::string_view key = "my_key"sv;
j5[key] = 100;

Metadata

Metadata

Assignees

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions