Skip to content

Cant modify existing numbers inside a json object #557

Description

@AMScaglione

Say for example I have something like

json j;
j["num"] = 0;

I can not do something like

j["num"] += 1;

as it gives me this error on runtime:

terminate called after throwing an instance of 'std::domain_error'
  what():  cannot use push_back() with number

I tried simplifying it to

j["num"] = j["num"] + 1;

but that gives me this error at compile time:
error: no match for 'operator+' (operand types are 'nlohmann::basic_json<>::value_type {aka nlohmann::basic_json<>}' and 'int')|

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions