Simple JSON parser. Why dont I find them?

Hi all

Im moving over from PHP to C++ and Im trying to find a Simple Json Parser but all I can find is big frameworks.

I imagine two files. one header file and one cpp file which will create an object called for example: json.

The object will then read the json text and be able to printout the results.

Im not looking for something that will save the world.
but something tiny that handles strings, and integers would be enough.

any suggestions besides jsonorg and such that provides a smal parser?
Oh, you need a parsing utility ... Make your own. I believe in you! However, you'll need to solidify your knowledge of C++ before you can start programming anything serious.

As for the parser design --
I recommend keeping most things as separated and modular as possible. Because you don't look too thrilled to make something big that supports all kinds of parsing, and you want "JSON parsing ?" I recommend that you still aim for high-flexibility, but without writing more code than you expect. You'll probably need to understand basic memory management for handling long lengths of text that needs to be parsed.

Take a skim through these to see what this takes:
http://www.cs.vu.nl/~dick/PTAPG.html
http://www.cs.vu.nl/~dick/MCD.html

They're just some info about books written by Dick Grune and a few other co-authors. But nevertheless it still may be interesting for you (as it was for me). EDIT: The first includes a PDF file of the full book!

Sorry, I don't actually know what JSON parsers are, although I know how parsing in general works (so whatever)...
Last edited on
How about json-cpp? http://sourceforge.net/projects/jsoncpp/

Fairly straightforward to use and cross platform too.
The Boost Property Tree library reads and writes JSON.

http://www.boost.org/doc/libs/1_46_1/doc/html/property_tree.html
Try the UniversalClass, if your coming from PHP I think you will find that it is what you are looking for. There is an example and full reference on the site.

http://www.greatpanic.com/code.html

The UniversalContainer acts much like a PHP variable, becoming a dictionary, array, or scalar depending on what you first shove into it. JSON functionality is provided by a pair of routines that serialize and deserialize to json format (see the section on I/O routines). Look at the web routines if you need a one line method to HTTP post a json object.
Topic archived. No new replies allowed.