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

Casting of json value results in std::domain_error

I am trying to iterate over an array in a json file to retrieve an entry with an ID. The value that I want to compare it to is not a string (the json default type), but an uint64_t. For testing purposes, I wrote this simplified example: #include…
DocDriven
  • 3,726
  • 6
  • 24
  • 53
0
votes
2 answers

How to convert nlohmann json to uint8_t array?

I would like convert my created json object to array of uint8_t[1000]. I tried something like this: nlohmann::json j_file; j_file["number"] = 2; j_file["example"] = "dog"; uint8_t parsed_json[1000] ={0}; auto str =…
Creatorek
  • 9
  • 3
0
votes
1 answer

Why is decltype for nlohmann json object different?

How do I extract information of underlying datatype from nlohmann object? Since the values are stored as primitive datatypes in the json why don't it give the output like a and b below? I see typedef as below for ordered…
Sreeraj Chundayil
  • 5,548
  • 3
  • 29
  • 68
0
votes
1 answer

Who deletes previous nlohmann json object resources when value is replaced?

I have a key and I want to change the value of the key with another json object. json newjs = ...; json tempjs = ...; newjs["key"] = tempjs["key"]; What will happen to the data existed in newjs["key"] previously? Will nlohmann class…
Sreeraj Chundayil
  • 5,548
  • 3
  • 29
  • 68
0
votes
0 answers

Parsing Json value after using the nlohmann:Json Convertor for map to Json

I am using the nlohmann::Json to converting the map to stringJson in c++ side. using that stringjson, I have passed entire Json to C# side using PINVOKE. I am struggling to parse the Json when folder is having multiple data. For…
Satyam Mishra
  • 333
  • 3
  • 10
0
votes
0 answers

scalable way to create new instance of a specific class/subclass from JSON input in C++

I am looking for a way to load a specific class/subclass type based on JSON input. For example, I have the following JSON file "type" : "RenderVertices" "RenderComponent": { "vertex": { "xcoords" : [0, 1, 1, 0] "ycoords" : [0, 0, 1, 1] …
0
votes
1 answer

Fetching api with nlohmann/json

I want to use api with c++ and when I searched I found nlohmann/json library it looks really popular but no one talks about how to get the array that fetch function provides . How can I get the information from the api as variables in my cpp file
0
votes
0 answers

Adding XPointer/XPath searches to ALL(?) C++ JSON libraries, is it doable?

Is it possible to extend all(?) existing C++ JSON libraries with XPath/XPointer or subset with just one C++ implementation? At least those with iterators for object and array values? I have reviewed three C++ JSON libraries (reviewing nlohmann,…
Per Ghosh
  • 449
  • 5
  • 10
0
votes
0 answers

Process big size of file and memory management

I tried to read and parse (using nlohmann library) a Json file that is almost 90MB using this code: std::ifstream ifs("data.json"); json jsonFile = json::parse(ifs); The Json file to parse has almost 14000 array elements that need to be…
Ali Sepehri-Amin
  • 493
  • 1
  • 6
  • 18
0
votes
0 answers

CMake "find_package" found the package but the compiler cant find the include files

I'm trying to build a program that uses nlohmann::json but I'm having an issue with the includes. As per the instructions I'm using find_package(nlohmann_json 3.9.0 REQUIRED) and CMake will find the package but when I build I get an error telling…
dominique120
  • 1,170
  • 4
  • 18
  • 31
0
votes
1 answer

C++ Nlohman::json third-party support not compiling

I'm using nlohmann::json to (de)serialize some C++ objects in JSON. I haven't yet understood how to set up the code to work with a third-party library (SoapySDR). My code is in the global namespace in this example, while the SoapySDR code is in…
0
votes
0 answers

Is it possible to serialize nested/complex classes with nlohmann/json?

I would like to use nlohmann/json to serialize a tree, but I am unsure if nlohmann/json provides the necessary features. Features about which I am unsure: Serialization of nested types. I am serializing a tree after all... Serialization of…
User12547645
  • 6,955
  • 3
  • 38
  • 69
0
votes
0 answers

How to solve this Floating Point expection: 8 error

This program is suppose to take a json in the format of a dict. The keys are zipcodes and the values are vectors of rent prices. When i run it using g++ I get a floating point exception 8: error. To my knowledge that error only triggers if the value…
0
votes
0 answers

Serializing cv::Mat with nlohmann/json lib

I would like to serialize my own Camera class with the nlohmann/json library: class Camera { private: std::string name_; std::string camera_calibration_filename_; cv::Mat intrinsics_; cv::Mat distortion_; public: Camera() =…
Hannes
  • 1
0
votes
1 answer

How to parse Json file only as a raw string value in cpp. I am using nlohmann json library for parsing

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()){…
Sid
  • 1