Hi all,
I am currently trying to parse a JSON file, but cannot figure how to achieve
this task (see for instance
http://ax.itunes.apple.com/WebObjects/MZStoreServices.woa/wa/wsSearch?term=sudoku&entity=software&limit=1
).
Here is a piece of code:
#ifndef ITUNES_JSON_STRUCTURE_HPP
#define ITUNES_JSON_STRUCTURE_HPP
#include
#include <string>
class itunes_json_structure
{
public:
void load(const std::string &filename);
boost::property_tree::ptree m_ptree;
};
#endif // ITUNES_JASON_STRUCTURE_HPP
#include "itunes_jason_structure.hpp"
#include
#include <iostream>
using namespace std;
void itunes_json_structure::load(const string &filename)
{
using boost::property_tree::ptree;
try
{
// Load the JSON file into the property tree. If reading fails
// (cannot open file, parse error), an exception is thrown.
read_json(filename, m_ptree);
cout << "resultCount = " << m_ptree.get<string>("resultCount") << endl;
ptree all_results = m_ptree.get_child("results");
// HERE!!! How can I read the content of the "results" node????
}
catch(exception &e)
{
throw e;
}
}
I am unable to read the content of the "results" node. Could you please give
me some help?
Regards,
Olivier