0

I have a json file

which looks something like this

{accessvalue: xyz-verylongvalue ,Type:abc}

I am parsing it using nlohmann json as given below:

std::ifstream ifs(PATH);
auto config= json::parse(ifs);
if (config.find("accessvalue")!=config.end()){  
string somevalue= config["accessvalue"].get<string>();
}

The above gives me a string value but next function expects the value in raw form. how do i convert "somevalue" to raw string or parse only the raw part.

Sid
  • 1

1 Answers1

0

std::string has a c_str() member, which returns C string (raw string). So, you need somevalue.c_str().

nicolai
  • 1,140
  • 9
  • 17
  • It does not help. I need to it to behave exactly R"(stringvalue)" works because this seems to work for my code and runs with run time errors – Sid Jul 26 '20 at 03:56
  • Can you show the exact signature of your "next function"? – nicolai Jul 26 '20 at 13:43