Questions tagged [nlohmann-json]

Use this tag for questions related to nlohmann JSON C++ library

nlohmann JSON is a header-only JSON class for Modern C++ (C++11)

Latest release: 3.9.1 released on 2020-08-06

See the github project

248 questions
0
votes
1 answer

nlohmann JSON C++ Include issue

I'm currently having an issue to where visual studio code is not recognizing the include of the json.hpp file no matter what I do in the IDE, I don't admittedly know if the issue is being caused by the IDE, my own silly mistake, or by the way the…
tommy61157
  • 164
  • 2
  • 13
0
votes
0 answers

Why is the 2nd time I try to change my JSON to string not working(the output window won't show up, even I have breakpts or getchar)?.

I am trying to convert my JSON object to a string in test case 1 and 4. When test case 4 is removed, the code works properly, like the output shows up. But when I include test case 4, the code won't run. VS Code says segmentation error. I tried…
RSA
  • 1
0
votes
2 answers

How to read JSON content as it is in C++?

I am trying read a text file which has Valid JSON content but not string. The below code works fine if it is a string dump. For example - if file contents are like this "{ \"happy\": true, \"pi\": 3.141 }" then it will parse without errors. Now I…
ajayramesh
  • 3,576
  • 8
  • 50
  • 75
0
votes
2 answers

JSON parsing using nlohmann json

I am trying to parse the JSON structure using nlohmann's json.hpp . But I am not to create the JSON structure from the string. I have tried all the way, but still it is failing. My requirement is to: 1) Create the JSON structure from the…
Hemant Yadav
  • 307
  • 1
  • 4
  • 19
0
votes
1 answer

c++ return type of function returning json array via nlohmann json.hpp

I am parsing a json file using nlohmann's json.hpp. The part of the json file I am concerned with looks like this: "image_captureOptions": { "captureInterval" : 1000, "captureLimit" : 5, "imageExtension" : "jpg", "imageResizeDims" :…
interwebjill
  • 920
  • 13
  • 38
0
votes
2 answers

C++ nonlohmann json read child object

i'm actually working on a little program and i need to read a json file. i'm using C++ and the nlohmann json libraries. My current code int main(int argc, const char** argv){ ifstream ifs("Myjson.json"); json j = json::parse(ifs); cout…
user8639911
0
votes
2 answers

How to properly parse JSON objects in a Java+C++ TCP connection?

So I want to have a TCP connection between a Java client and a C++ server. Think of the client as an input device and the C++ server should receive JSON objects, parse them and use them in a game. It seems like the connection is established…
Joana
  • 23
  • 3
-1
votes
1 answer

c++ json read value from [ ]

i wanna read Json file with c++, im using dev c++. Json…
TheOwnIt
  • 1
  • 1
-1
votes
1 answer

nlohmann json insert object in array

The json file is: { "vis.DataSet": [], "backup": [] } I want to insert 2 objects {a=1,b=2,c=3} and {a=4,b=5} to "vis.DataSet" key. Then the json become as { "vis.DataSet": [ { "a" : 1, "b" : 2, "c" : 3 }, { "a" : 4, …
minjiew
  • 1
  • 1
-1
votes
1 answer

How to insert an object into an object with nlohmann json library

I am unable to insert a JSON object into another object using c++ library “nlohmann json”. An array is inserted instead of an object. I want to get And it turns out The code I am using: playersSkins.push_back(json::object_t::value_type(playerName,…
Er2n
  • 1
  • 2
-1
votes
1 answer

erasing nlohmann::json object during iteration causes segmentation fault

I have a simple database consisting of objects with strings containing unix time as keys and strings containing instructions as values I want to iterate though the database and erase any object who's key is smaller that current time ( so erase…
Serfer
  • 3
  • 1
-1
votes
1 answer

How to get size of nlohmann json object in memory?

How do I get the size of nlohmann object in memory in bytes? The .size() operator gives the number of elements. I have a lot of sub keys and elements. What can I do to find it?
Sreeraj Chundayil
  • 5,548
  • 3
  • 29
  • 68
-1
votes
1 answer

Converting to data structure using from_json

I have the below program where I am trying to parse one json into a structure. See that I am the structure Address which I am trying to load from the json string. However there is some exception. #include #include using…
Soumyajit Roy
  • 463
  • 2
  • 8
  • 17
-1
votes
1 answer

Loop over json array items

I have a C++ code with an nlohmann::json array-type object. So it kinda looks…
conni
  • 67
  • 6
-1
votes
1 answer

Writing to a JSON file using c++?

Suppose I have a JSON object as follows : { "Tickets": [ { "Name" : "Alice Parker", "Age" : "21", } ] } The above text is from a Names.json file. I want to append more objects into Tickets…
1 2 3
16
17