This repository is private.
All pages are served over SSL and all pushing and pulling is done over SSH.
No one may fork, clone, or view it unless they are added as a member.
Every repository with this icon (
) is private.
Every repository with this icon (
This repository is public.
Anyone may fork, clone, or view it.
Every repository with this icon (
) is public.
Every repository with this icon (
jsonxx /
| name | age | message | |
|---|---|---|---|
| |
.gitignore | Mon Dec 01 08:05:32 -0800 2008 | |
| |
LICENSE | Sat Dec 05 17:40:23 -0800 2009 | |
| |
Makefile | Thu Dec 04 18:05:00 -0800 2008 | |
| |
README.textile | Fri Dec 05 14:26:40 -0800 2008 | |
| |
jsonxx.cc | Sun Sep 06 02:47:29 -0700 2009 | |
| |
jsonxx.h | Sun Sep 06 02:47:29 -0700 2009 | |
| |
jsonxx_test.cc | Sun Sep 06 02:30:50 -0700 2009 |
README.textile
Introduction
JSON++ is a light-weight JSON parser written in C++.
Why another JSON parser?
Perhaps because web service clients are usually written in dynamic
languages these days, none of the existing C++ JSON parsers suite my
needs very well, so I wrote one to used in another project. My goals
for JSON++ were:
- Efficient in both memory and speed.
- No third party dependencies. JSON++ only depends on the standard C++ library.
- Cross platform.
- Robust.
- Small and convenient API. Most of the time, you only need to call one function and two function templates.
- Easy to integrate. JSON++ only has one source file and one header file. Just compile the source file and link with your program.
Usage
The following snippet is from one of the unit tests. It’s quite self-descriptive.
string teststr(
"{"
" \"foo\" : 1,"
" \"bar\" : false,"
" \"person\" : {\"name\" : \"GWB\", \"age\" : 60},"
" \"data\": [\"abcd\", 42]"
"}"
);
istringstream input(teststr);
Object o;
assert(o.parse(input));
assert(1 == o.get<long>("foo"));
assert(o.has<bool>("bar"));
assert(o.has<Object>("person"));
assert(o.get<Object>("person").has<long>("age"));
assert(o.has<Array>("data"));
assert(o.get<Array>("data").get<long>(1) == 42);
assert(o.get<Array>("data").get<string>(0) == "abcd");
assert(!o.has<long>("data"));







