Jsoncpp

From kangssu
Jump to: navigation, search

{{tag>cpp jsoncpp json}}

jsoncpp
jsoncpp build

다운로드 : https://github.com/open-source-parsers/jsoncpp/releases


상세 빌드 내용 : https://github.com/open-source-parsers/jsoncpp/wiki/Building

요약 :

mkdir -p build/release cd build/release cmake -DCMAKE_BUILD_TYPE=release -DBUILD_STATIC_LIBS=ON -DBUILD_SHARED_LIBS=OFF -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX=/cross/jsoncpp ../..

jsoncpp example

  1. include "json/json.h"

int main() {

   Json::Value root;
   Json::Value encoding;
   root["key"] = "gogogo";
   root["persons"] = Json::arrayValue;
   {
       Json::Value person; 
       wifiList["name"] = "ksoo";
       wifiList["number"] = "010-737373";
       root["persons"].append(person);
   }
   {
       Json::Value person; 
       wifiList["name"] = "ksoo";
       wifiList["number"] = "010-737373";
       root["persons"].append(person);
   }
   
   Json::FastWriter fw;
   std::cout << root << std::endl;
   std::cout << fw.write(root) << std::endl;

}