JSONcpp lib 추가할때 메인함수 (에러 남 링크에러.. 결국 헤더파일이랑 소스 파일만 추가해서(라이브러리 제외) 사용 ㅠㅠ)

// json_test.cpp : 응용 프로그램에 대한 진입점을 정의합니다.
//

#include "stdafx.h"
#include "json_test.h"
#include "json.h"
#include <string>
#include <iostream>
#pragma comment(lib, "json_vc71_libmtd.lib")

int main(int argc, char ** argv)
{
 std::string jsonStr = "{     \
  \"encoding\" : \"UTF-8\",    \
  \"plug-ins\":       \
    [\"python\",     \
    \"c++\",      \
    \"ruby\"],      \
  \"indent\" :       \
    {\"length\" : 3,    \
    \"use_space\":true }   \
  }";

 Json::Value root;
 Json::Reader reader;
 bool parsingSuccessful = reader.parse(jsonStr,root);
 if(!parsingSuccessful)
 {
  std::cout << "Failed to parse configuration \n" << reader.getFormatedErrorMessages();
  return -1;
 }
 std::cout << "jsoncpp has been ready to work" << std::endl;

 std::string strEncoding = root.get("encoding", "UTF-8").asString();
 std::cout<<"[Encoding] : "<<strEncoding <<std::endl;
 std ::string strPlugin;
 const Json::Value plugins = root["plug-ins"];

 for(int index = 0; index <plugins.size(); ++index)
 {
  strPlugin = plugins[index].asString();
  std::cout <<"[plugin] : " <<strPlugin <<std::endl;
 }
 std::cout << "[Indent Length] :"<<root["indent"].get("length",100).asInt()<<std::endl;
 std::cout << "[Indent Use Space]: "<<root["indent"].get("length",100).asBool()<<std::endl;
 return 0;
}
 

'and so on' 카테고리의 다른 글

아이디어가 고갈되었을 때의 처방전 20  (0) 2012.08.28
작업 디렉터리  (0) 2012.08.13
dll  (0) 2012.07.10
야구게임  (0) 2012.06.22
3n+1문제  (0) 2012.06.21