jsoncpp

how to write a cmake Module for jsoncpp?

我们两清 提交于 2019-12-10 04:38:54
问题 I want to use jsoncpp for writing a C++ code in order to parse a JSON file. Let me explain what I did. I created a CMakeLists.txt and I made a FindJsoncpp.cmake along with a simple c++ file to test jsoncpp . When I compile the C++ source without cmake using -I/usr/include/jsoncpp/ -ljsoncpp it works fine. but when I try to build it using cmake it cannot find json.h header file that I included in my c++ source code. here is my CMakeLists.txt : cmake_minimum_required (VERSION 2.6) project

Jsoncpp FastWriter right trim

依然范特西╮ 提交于 2019-12-08 05:58:24
问题 Jsoncpp FastWriter method why last line append blank? It's for there an method Json::StreamWriterBuilder and indentation field. I how to use this method? for no lines. Fixed please look answer. Dont like code: Json::Value root; root["name"] = "Arda"; Json::FastWriter out; std::cout << "'" << out.write(root) << "'" << std::endl; // Result: '{"name": "Arda"} ' 回答1: I now StreamWriterBuilder method using for nice result ! Json::StreamWriterBuilder wbuilder; wbuilder["indentation"] = ""; std:

Fatal error with jsoncpp while compiling

橙三吉。 提交于 2019-12-07 22:32:17
问题 Am new to cpp but as per project requirements i need to consume rest api and parse the response. Am able to call api & capture the response but not able to parse it using JSONCPP library. These are the steps i followed to parse json: Used this command to install libjsoncpp in ubuntu sudo apt-get install libjsoncpp-dev Downloaded json source files and copied json header files into project folder Compiling cpp using this command gcc -o test.out test.cpp -ljson it is always giving fatal error:

How to insert a map or vector to generate a json string (jsoncpp)

时光总嘲笑我的痴心妄想 提交于 2019-12-07 16:11:59
问题 Hi I would like to do something easy with the lib jsoncpp like this: std::map<int,string> mymap; mymap[0]="zero"; mymap[1]= "one"; Json::Value root; root["teststring"] = "m_TestString"; //it works root["testMap"] = mymap; //it does not work Json::StyledWriter writer; string output = writer.write( root ); The error is : error C2679: binary '=' : no operator found which takes a right-hand operand of type 'std::map<_Kty,_Ty>' Do you have an idea to solve this,? I understand that json::value can

Linux下hiredis、jsoncpp的安装

左心房为你撑大大i 提交于 2019-12-07 09:06:04
以下库将安装到/usr/local/lib,头到/usr/local/include hiredis的安装 下载https://github.com/redis/hiredis 解压 cd hiredis make make install linux下正确安装jsoncpp scons下载地址:wget http://prdownloads.sourceforge.NET/scons/scons-2.2.0.tar.gz Jsoncpp 下载地址 http://sourceforge.net/projects/jsoncpp/files/latest/download?_test=goal #tar -zxvf scons-2.1.0.tar.gz #cd scons-2.1.0 #python setup.py install #cd .. #tar -zxvf jsoncpp-src-0.5.0.tar.gz #cd jsoncpp-src-0.5.0 #scons platform=linux-gcc #cp libs/linux-gcc-7/* /usr/local/lib #cp -r /home/lgl/下载/jsoncpp/jsoncpp-src-0.5.0/include/json /usr/local/include/json 来源: oschina 链接:

Problems including jsonCpp headers

不想你离开。 提交于 2019-12-06 07:15:43
问题 I'm trying to implement the jsoncpp libraries in my C++ code, I wrote a simple piece of code just to try it out, and it's not even compiling. #include <stdio.h> #include <stdlib.h> #include <stddef.h> #include <string.h> #ifndef json_included #define json_included #include "jsoncpp\include\json\json.h" #endif //#include "json\jsonC\json.h" int main(int argc, char **argv) { std::string example = "{\"array\":[\"item1\", \"item2\"], \"not an array\":\"asdf\"}"; Json::Value value; Json::Reader

Fatal error with jsoncpp while compiling

一世执手 提交于 2019-12-06 04:25:44
Am new to cpp but as per project requirements i need to consume rest api and parse the response. Am able to call api & capture the response but not able to parse it using JSONCPP library. These are the steps i followed to parse json: Used this command to install libjsoncpp in ubuntu sudo apt-get install libjsoncpp-dev Downloaded json source files and copied json header files into project folder Compiling cpp using this command gcc -o test.out test.cpp -ljson it is always giving fatal error: json/json.h: No such file or directory #include <json/json.h> ^ compilation terminated. Didn't find any

How to insert a map or vector to generate a json string (jsoncpp)

别等时光非礼了梦想. 提交于 2019-12-06 01:56:04
Hi I would like to do something easy with the lib jsoncpp like this: std::map<int,string> mymap; mymap[0]="zero"; mymap[1]= "one"; Json::Value root; root["teststring"] = "m_TestString"; //it works root["testMap"] = mymap; //it does not work Json::StyledWriter writer; string output = writer.write( root ); The error is : error C2679: binary '=' : no operator found which takes a right-hand operand of type 'std::map<_Kty,_Ty>' Do you have an idea to solve this,? I understand that json::value can not accept a map but to create a json file it should be, right? thank you very much Yes, this isn't

JsonCpp - when having a json::Value object, how can i know it's key name?

我们两清 提交于 2019-12-06 01:39:07
问题 Let suppose I have this Json file: [ { "id": 0 } ] using jsoncpp, i can have a Json::Value object by doing this: Json::Value node = root[0u]["id"]; OK, somewhere else in the code, I'm getting that node object, and I want to get some info out of it. I can get its value, like this: int node_value = node.asInt(); But how can I get its NAME? (i.e the "id"). It should be something like: string node_name = node.Name(); //or maybe: string node_name2 = node.Key(); but I can't find anything similar.

how to write a cmake Module for jsoncpp?

房东的猫 提交于 2019-12-05 10:47:10
I want to use jsoncpp for writing a C++ code in order to parse a JSON file. Let me explain what I did. I created a CMakeLists.txt and I made a FindJsoncpp.cmake along with a simple c++ file to test jsoncpp . When I compile the C++ source without cmake using -I/usr/include/jsoncpp/ -ljsoncpp it works fine. but when I try to build it using cmake it cannot find json.h header file that I included in my c++ source code. here is my CMakeLists.txt : cmake_minimum_required (VERSION 2.6) project (Parser) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/") include