open-source-parsers / jsoncpp

A C++ library for interacting with JSON.
Other
8.06k stars 2.63k forks source link

Adding Values after call to clear() fails. #1533

Open VicKrawciw opened 6 months ago

VicKrawciw commented 6 months ago

Describe the bug Adding Values after call to clear() fails.

To Reproduce Steps to reproduce the behavior: 1. bool result = false;

Json::Value root; Json::Reader reader;

result = reader.parse(request, request + strlen(request), root, false); if (result) { std::string command; int advanced; try { command = root[0]["command"].asString(); advanced = root[0]["advanced"].asInt();

  //Done with command
  root.clear();

  if (command.compare("GetStationDesc") == 0)
  {
   // If we use the root above after clear() this addition fails.
    // Json::Value root;
    root["name"] = "S2000Test";
    root["type"] = "S2000";

Expected behavior After the root.clear() I should be able to add items.

Desktop (please complete the following information):

Additional context Add any other context about the problem here.