Date: 2015-08-03 04:05 pm (UTC)
recoder: (masked)
From: [personal profile] recoder
json-test.Poco.cc
#include <iostream>
#include <fstream>
#include <string>
#include "Poco/JSON/JSON.h"
#include "Poco/JSON/Parser.h"
#include "Poco/JSON/Handler.h"
#include "Poco/JSON/Object.h"
#include "Poco/Dynamic/Var.h"
#include "handler.hh"

const char* JSON_FILE = "test-2.json";

using namespace std;
using namespace Poco;
using namespace Poco::JSON;
using namespace Poco::Dynamic;

void parse_file(const std::string& buffer)
{
    Parser parser;
    Var result = parser.parse(buffer);

    DynamicStruct data = *(result.extract<Object::Ptr>());
    Var items = data["items"];

    for(auto item = items.begin(); item != items.end(); ++item)
    {
        int v = (*item)["data"][3][3].convert<int>();
    }
}

int main(void)
{
    ifstream ifs(JSON_FILE);
    std::string buffer((std::istreambuf_iterator<char>(ifs)), std::istreambuf_iterator<char>());

    for (int j = 0; j < TIMES; ++j)
        parse_file(buffer);
}
This account has disabled anonymous posting.
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

December 2024

S M T W T F S
1234567
891011121314
15161718192021
22232425 262728
293031    

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Jan. 24th, 2026 08:28 am
Powered by Dreamwidth Studios