Questions tagged [jsoncpp]

jsoncpp is an open source JSON reader and writer for C++

jsoncpp is an implementation of a JSON reader and writer in C++. JSON (JavaScript Object Notation) is a lightweight data-interchange format. It is easy for humans to read and write. It is easy for machines to parse and generate.

318 questions
0
votes
1 answer

JsonCpp can't find file when I use get_current_dir_name()

I am trying to parse a json file within my program: #include #include #include #include int main(){ std::string plan { get_current_dir_name() }; plan +=…
NotALolicon
  • 31
  • 1
  • 7
0
votes
0 answers

Unable to read json from a file using jsoncpp

I have looked for answers on stackoverflow and none of them helped me so I am putting this question again. I have a config file config.json which looks like this : { "key1" : "value1", "key2" : ["a", "b", "c"] } And I am trying this to read…
vectar
  • 61
  • 1
  • 2
  • 8
0
votes
0 answers

How to make my JsonFormat not error with JsonCPP when I write to a json file?

I was building a quizbowl tracker to keep track of different facts and definitions but my JSON formatting is not working well. When I tried it, the json file throws an error, and I do not know how to fix it. So, does anyone know how to fix this…
0
votes
0 answers

JSONCPP : Using a pointer ( as said in documentation) in place of reference results in segmentation fault

In the JSONCPP library's documentation ( here ), it says that the function Json::parseFromStream() accepts a Json::Value * as one of its arguments. However it results in a segmentation fault as in the following snippet : void Coco::read_gt(const…
0
votes
1 answer

How to set value dynamically with JsonCpp?

I need to write a function that will take two arguments, a key path and a value, and will populate a JSON object. However, it does not work because the values I'm using are passed by value; I do not know how to refactor the function so pointers are…
Yanick Rochon
  • 51,409
  • 25
  • 133
  • 214
0
votes
1 answer

jsoncpp is having trouble reading my Gson output

I have a java application that outputs data in Json format (via Gson). I write that data to a file. That file is then read by a C++ application. The C++ application is using jsoncpp to deserialize the json. However, it appears that the C++…
Ironchef
  • 26
  • 4
0
votes
0 answers

Error when using Json Library: ld: symbol(s) not found for architecture x86_64

I try to read a file as json in C++. #include #include #include int main() { std::ifstream template_file("data.json", std::ifstream::binary); Json::Value template_data; template_file >> template_data; …
Andy
  • 1,072
  • 2
  • 19
  • 33
0
votes
1 answer

How to access the key of a jsoncpp Value

I kind of feel stupid for asking this, but haven't been able to find a way to get the key of a JSON value. I know how to retrieve the key if I have an iterator of the object. I also know of operator[]. In my case the key is not a known value, so…
Amir
  • 421
  • 1
  • 4
  • 14
0
votes
1 answer

Refer to json individual objects in cpp crow

i am using a cpp crow library and i am having difficulty in accessing individual objects i am attaching my code here. CROW_ROUTE(app,"/hello/") ([](string name){ crow::json::wvalue x; x["name"] = "llllds"; x["Town"] = "Texas"; …
0
votes
1 answer

JsonCpp - modify an array of objects

I have a following array of objects in JsonCpp::Value: [{"foo": "bar", "baz": ["Hello", "World"]}, {"Hello": "99bottles", "baz": ["bar", "foo"]}, {"beer": "hello", "world": ["foo"]}.... ] I have to iterate over them and alternate them (remove some…
user3193620
  • 173
  • 1
  • 11
0
votes
1 answer

Stack corruption with jsoncpp

I am getting stack corruption saying "Run-Time Check Failure #2 - Stack around the variable 'root' was corrupted." with following code: #include #include #include #include int main() { Json::Value…
0
votes
0 answers

c++ Jsoncpp errors

#include #include #include #include using namespace std; static size_t writecallback(void* contents, size_t size, size_t nmemb, void* userp) { ((std::string*)userp)->append((char*)contents,…
yFlameBR
  • 1
  • 1
  • 1
0
votes
2 answers

how to compile a git repo in yocto with jsoncpp libary?

I wrote a recipe to compile a git repo in Yocto. The repository contains a Makefile to compile the code. The first time I was able to compile the code in Yocto, but when I added the jsoncpp library in my code, Yocto not able to compile it. It is…
0
votes
1 answer

How to debug jsoncpp in eclipse

I'm using jsoncpp library in my cpp project on eclipse IDE, and I'm using a lot of Json::Value objects in my application. When debugging my program, I can't see the real content of the Json::Value objects on the watch window, I can only see some…
0
votes
1 answer

simple reading of a json file using Jsoncpp

If I have a json file: { "key1" : "value1", "key2" : "value2" } using: Json::Value root; Json::Reader reader; std::ifstream in(filePath.c_str()); if (!in) { std::string errReason("Cannot open the settings file '"); errReason += filePath; …
azuric
  • 2,679
  • 7
  • 29
  • 44