jsoncpp

Using libCurl and JsonCpp to parse from https webserver

て烟熏妆下的殇ゞ 提交于 2019-12-21 18:31:14
问题 So I've been looking around the internet for a basic example of parsing JSON using libcurl and jsoncpp but I've not been able to find one. Could someone please point me in the right direction or specify here, a simple example of using libcurl and jsoncpp, downloading json from a specified webpage (the link itself ending in .json so it will be pulling json directly) parsing it and printing it. All help is appreciated. Thanks! Euden 回答1: Here's a self-contained example to a) HTTP GET a JSON

JSONCPP Writing to files

杀马特。学长 韩版系。学妹 提交于 2019-12-20 09:29:41
问题 JSONCPP has a writer, but all it seems to do is get info from the parser and then output it into a string or a stream. How do I make it alter or create new objects, arrays, values, strings, et cetera and write them into the file? 回答1: #include<json/writer.h> Code: Json::Value event; Json::Value vec(Json::arrayValue); vec.append(Json::Value(1)); vec.append(Json::Value(2)); vec.append(Json::Value(3)); event["competitors"]["home"]["name"] = "Liverpool"; event["competitors"]["away"]["code"] =

Binary data JSONCPP

a 夏天 提交于 2019-12-19 11:58:24
问题 I am trying to use JSON cpp with VS2008. Can anyone tell me is it possible to pack binary data into JSON format? I am reading a image file into char* buffer , and putting it in JSON::Value . But when i try to parse it, I don't find the buffer contents in the JSON object. Code is as follows. Json::Value root; Json::Reader reader; Json::StyledWriter writer; int length; char * buffer; ifstream is; is.open ("D:\\test.j2k", ios::binary); // get length of file: is.seekg (0, ios::end); length = is

Compiling and Using JSONCPP on Visual Studio10 with Boost

回眸只為那壹抹淺笑 提交于 2019-12-17 23:25:13
问题 I have recently compiled the SVN version of JSONCPP using the VS71 makefiles. It worked, but I get a lot of linker errors 1>msvcprt.lib(MSVCP100.dll) : error LNK2005: "public: __int64 __thiscall std::basic_streambuf<char,struct std::char_traits<char> >::sputn(char const *,__int64)" (?sputn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAE_JPBD_J@Z) already defined in JSONCPP.lib(json_writer.obj) 1>msvcprt.lib(MSVCP100.dll) : error LNK2005: "public: void __thiscall std::basic_ostream<char

How to read a JSON file containing multiple root elements?

感情迁移 提交于 2019-12-17 10:02:41
问题 If I had a file whose contents looked like: {"one": 1} {"two": 2} I could simply parse each separate line as a separate JSON object (using JsonCpp). But what if the structure of the file was less convenient like this: { "one":1 } { "two":2 } 回答1: Neither example in your question is a valid JSON object; a JSON object may only have one root. You have to split the file into two objects, then parse them. You can use http://jsonlint.com to see if a given string is valid JSON or not. So I recommend

How to read a JSON file containing multiple root elements?

两盒软妹~` 提交于 2019-12-17 10:01:17
问题 If I had a file whose contents looked like: {"one": 1} {"two": 2} I could simply parse each separate line as a separate JSON object (using JsonCpp). But what if the structure of the file was less convenient like this: { "one":1 } { "two":2 } 回答1: Neither example in your question is a valid JSON object; a JSON object may only have one root. You have to split the file into two objects, then parse them. You can use http://jsonlint.com to see if a given string is valid JSON or not. So I recommend

jsoncpp. find object in array by matching value

ε祈祈猫儿з 提交于 2019-12-12 08:39:29
问题 I have this JSON object: {"books":[ { "author" : "Petr", "book_name" : "Test1", "pages" : 200, "year" : 2002 }, { "author" : "Petr", "book_name" : "Test2", "pages" : 0, "year" : 0 }, { "author" : "STO", "book_name" : "Rocks", "pages" : 100, "year" : 2002 } ] } For example, I need to find a book(s) which author key is equal to Petr . How can I do this? Right now I have this piece of code: Json::Value findBook(){ Json::Value root = getRoot(); cout<<root["books"].toStyledString()<<endl; //Prints

JsonCpp heap object handling memory management

廉价感情. 提交于 2019-12-12 06:45:31
问题 With JsonCpp I want to serialize big objects with limited stack resources on an embedded device. All the examples I found are using stack objects which will be copied into each other (I guess). I want to reduce the copying the Json::Value objects all the time, but still using clustered code -- so that each object just needs to know how to serialize itself. I prepared a minimal example, which orientates to the described memory management from this answer https://stackoverflow.com/a/42829726

Using JsonCpp on X-Cross platform library

做~自己de王妃 提交于 2019-12-11 09:44:31
问题 I'm making a library in C++ with OpenCV and JsonCpp towards building a library for Android and iOS. On testing my library for Android, I'm making the JNI files but when I try to load the library I'm getting java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "_ZN4Json6WriterD2Ev" referenced by "libXYZ.so"... and that's because I think I'm not building my Json library very well. The library that I use is this one: https://github.com/open-source-parsers/jsoncpp My Android.mk is:

Iterate over an array of JSON objects with jsoncpp

牧云@^-^@ 提交于 2019-12-11 02:29:55
问题 I have an array of JSON objects, jsonArr say, of the following kind: [ { "attr1" : "somevalue", "attr2" : "someothervalue" }, { "attr1" : "yetanothervalue", "attr2" : "andsoon" }, ... ] Using jsoncpp, I'm trying to iterate through the array and check whether each object has a member "attr1" , in which case I would like to store the corresponding value in the vector values . I have tried things like Json::Value root; Json::Reader reader; Json::FastWriter fastWriter; reader.parse(jsonArr, root)