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
-1
votes
1 answer

nlohmann json insert an array into another array

I want to take these two arrays: [1, 2, 5] [3, 4] and insert the [3, 4] into position 2 of [1, 2, 5]. The result would look like this: [1, 2, 3, 4, 5] How can I achieve this?
Ank i zle
  • 2,089
  • 3
  • 14
  • 36
-1
votes
1 answer

C++ json insert into array

I am using nlohmann json. I want to insert into an array. I know in javascript there is a Array.prototype.splice that allows you to insert into an array. Is there a similar way in nlohmann's json. I want this to happen: //from this: [1, 2, 3,…
Ank i zle
  • 2,089
  • 3
  • 14
  • 36
-1
votes
1 answer

How to delete nested json data using nlohmann c++

I have a below json data. I am using nlohmann json in C++. { "CompanyName": "XYZ Tech", "Created": "2019-10-16T20:14:29Z", "TxnId": "4509237", "Tags": [ { "ROIId": "Default", "Time": 71, …
S Andrew
  • 5,592
  • 27
  • 115
  • 237
-1
votes
1 answer

Getting null values while saving json data in file using nlohmann json

I am using nlohmann json to create ans save some json values. But when I look at the file, I get null values in between the json. Below is how it looks like: { "Created": "2019-07-03T13:54:32Z", "DataId": "BHI-201-U8", "Data": [ …
S Andrew
  • 5,592
  • 27
  • 115
  • 237
-1
votes
1 answer

C++ no matching function for call when using push_back in older json::nlohmann library

#include "json.hpp" #include #include #include struct json_node; using json_node_ptr = std::shared_ptr; struct json_node { int id; std::vector children; json_node(int _id) …
cateof
  • 6,608
  • 25
  • 79
  • 153
-1
votes
1 answer

Create JSON structure based on input variables

I have the following JSON file: { "outer_size":2, "inner_size":{ "length_one":2, "length_two":1 } } I will use this info to create a new JSON file, whose dimensions are determined by outer_size, inner_size, length_one and…
BillyJean
  • 1,537
  • 1
  • 22
  • 39
-2
votes
1 answer

Format JSON in C++

I'm trying to parse JSON in C++ with nlohmann/json library. But this library can't parse not formatted JSON. I get an error: libc++abi.dylib: terminating with uncaught exception of type nlohmann::detail::parse_error: [json.exception.parse_error.101]…
Natoly
  • 7
  • 3
-2
votes
2 answers

How to append in json file at specific position

I'm trying to append JSON objects to a file at specific position but I'm unable to do it as required. I get result but without "," separating the values, so they are separate JSON objects. I want to loop through JSON objects and append the result to…
Amy
  • 69
  • 2
  • 9
1 2 3
16
17