Add sandbox for jsoncpp toying around
[dueringa_WikiWalker.git] / sandbox / jsontest.cpp
blob3604e8c240276bb671dd2b456547ba95ca3c9b98
1 #include <string>
2 #include <sstream>
3 #include <json/json.h>
5 class Myexcept : public std::exception
7 public:
8 Myexcept(std::string message)
9 : message(message){};
10 ~Myexcept() throw(){};
11 const char* what() const throw()
13 return message.c_str();
15 private:
16 std::string message;
19 int main()
21 std::string json = "{\"batchcomplete\":\"\",\"query\":{\"normalized\":[{\"from\":\"Amundsen_Basin\",\"to\":\"Amundsen Basin\"}],\"pages\":{\"37082520\":{\"pageid\":37082520,\"ns\":0,\"title\":\"Amundsen Basin\",\"links\":[{\"ns\":0,\"title\":\"Abyssal\"},{\"ns\":0,\"title\":\"Arctic\"},{\"ns\":0,\"title\":\"Arctic Ocean\"},{\"ns\":0,\"title\":\"Cenozoic\"},{\"ns\":0,\"title\":\"Eurasian Basin\"},{\"ns\":0,\"title\":\"Gakkel Ridge\"},{\"ns\":0,\"title\":\"Lomonosov Ridge\"},{\"ns\":0,\"title\":\"Nansen Basin\"},{\"ns\":0,\"title\":\"Roald Amundsen\"},{\"ns\":0,\"title\":\"Seafloor spreading\"},{\"ns\":0,\"title\":\"Wilkes Basin\"}]}}}}";
22 Json::Reader reader;
23 Json::Value document;
24 std::istringstream jsondatastream(json);
25 jsondatastream >> document;
26 bool success = true; //reader.parse(json, document, false);
28 if(!success) {
29 throw Myexcept("Error parsing JSON");