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

Why jsoncpp append function will cause an assert error

I am a newer to Jsoncpp and I used it in my c++ projects。Sometimes I found a wired error like this: Json::Value val; val["1"] = 1; val["2"] = 2; Json::Value arr; arr["name"] = "wjx"; arr["age"] = 23; arr["id"] = 17777; val.append(arr); this will…
wenjx
  • 11
  • 3
0
votes
0 answers

JSONCPP Vector - Segmentation fault

I'm using JSONCPP to create a JSON document with parsed latitude and longitude but it always gives me segmentation fault. I already tried to create a C++ vector such as std::vector and after that include in JSON but the error…
shizde
  • 11
  • 5
0
votes
1 answer

Local variable to global variable

I'm very new to C++ so sorry if I'm making a really stupid mistake. I'm using JsonCPP to try read my config file and I wanted to store them in a global variable, but I can't seem to work out how to do it without it clearing as soon as the function…
0
votes
1 answer

throwing an instance of 'Json::LogicError'

Creating a JSON object using jsoncpp and have error when added in array as follows. Json::Value zone1; Json::Value coord; zone1["zoneID"] = "shop1"; zone1["stamp"] = "xxxxx"; zone1["gridSizeX"] = "50"; zone1["gridSizeY"] = "20"; zone1["gridScale"] =…
batuman
  • 7,066
  • 26
  • 107
  • 229
0
votes
0 answers

How to change the value of a variable in jsoncpp

I have a json-file { "X": "3.5", "Y": "4.4" } and I need to change the value of the variable x (increase it by 0.5) { "X": "4.0", "Y": "4.4" } I would like to read the file, change the variable and write the file. I have problems…
0
votes
1 answer

Appending an array to a Json Value in C++

I know that if I have some integer 'a' and 'b' that I can append them to a Value in Json: Value root; Value v = root["int"]; int a = 1; int b = 2; v.append(a); v.append(b); Resulting Json file: "int": [ 1, 2 ] But is there also a way…
Otherness
  • 385
  • 2
  • 16
0
votes
0 answers

Append multidimensional array to Jsoncpp

I have an existing json structure, and I'm trying to add a 2D array of doubles to a new Value in the json tree. Here's the function showing what I've tried to do, with the commented out option of defining a instead of a 2D array of doubles…
Otherness
  • 385
  • 2
  • 16
0
votes
2 answers

How to validate json file in C++?

Currently I have a JSON file (Test.json) with some valid data in json format and i'am trying to parse the data using a json object (readData) using JsonCpp, as below Json::Value readData; std::ifstream readFile("Test.json"); readFile >>…
Suchin Raj
  • 17
  • 2
  • 8
0
votes
1 answer

How to bind Python to C++ code that includes Jsoncpp?

Working on a code that enables Python to call a C++ code compiled into shared library file (.so file) via Python's ctypes module, using the standard ctypes.CDLL method. The C++ code performs the numerical calculations and the Python code mainly…
X...
  • 173
  • 1
  • 2
  • 12
0
votes
1 answer

Unable to compile simple jsoncpp program with Eclipse on LInux

The File is at the location /home/shivang/Desktop and the filename is sh1.cpp Source code for the file is given below #include iostream #include json/json.h #include json/reader.h using namespace std; using namespace Json; int main() { …
0
votes
3 answers

Linking problem when using jsoncpp library

I have a problem related to the parsing of a JSON file. It is composed of an array of JSON objects and the program I've developed parses this by just iterate over the various { ... } elements found in the file. The elements (in the JSON file, these…
Carmine
  • 109
  • 2
  • 8
0
votes
1 answer

Parse json array string using jsoncpp

I have this JSON: [{"header": "test" , "test2" : "test2"}] I'm trying to parse this using jsoncpp. Here's my code snippet: Json::CharReaderBuilder builder; Json::CharReader *reader = builder.newCharReader(); Json::Value root; bool parseRet =…
anas
  • 1
  • 1
  • 1
0
votes
0 answers

SEGV while parsing json file C++

My program to load json file gives SEGV intermittently with following signature. 034613:/../lib/libtcmalloc.so.4(operator new(unsigned long) 0xc9)[0x7f493d215f99] /lib/libjsoncpp.so(Json::Value::Value(Json::Value const&)…
0
votes
1 answer

Is there a way to use variable as the key in jsoncpp?

I wrote a function to save directory structure to json file.I'm using Jsoncpp libary to encode json.And I'm using c++17.But it throws a Json::LogicError. It says that "Json::Value::operator[](ArrayIndex) requires arrayValue".Here is the…
0
votes
1 answer

Reading a JSON file with jsoncpp

I am trying to use integer values from a list in a JSON file, but I seem to be having trouble with parsing the file. I tried changing the line "Reader reader;" to "CharReader reader;", but that doesn't work with the parse function. #include…
Ham Sandwich
  • 11
  • 1
  • 1