Skip to content

Instantly share code, notes, and snippets.

@mattn
Created July 2, 2009 03:29
Show Gist options
  • Save mattn/139255 to your computer and use it in GitHub Desktop.
Save mattn/139255 to your computer and use it in GitHub Desktop.
#include <iostream>
#include "picojson.h"
using namespace std;
using namespace picojson;
int main(void) {
value v;
const char *text = "{\"arr\": [1,2,3], \"obj\": {\"foo\": \"bar\"}}";
string err = parse(v, text, text + strlen(text));
cout << "is error? : " << (err.empty() ? "no" : "yes") << endl;
cout << "is object?: " << (v.is<object>() ? "yes" : "no") << endl;
cout << "is array? : " << (v.is<array>() ? "yes" : "no") << endl;
//cout << v.get("arr").to_str() << endl;
cout << v.get("arr").to_str() << endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment