couchdeveloper / JPJson

A JSON Framework for Objective-C and C++
Other
27 stars 2 forks source link

JPJson Package

JPJson is an Objective-C framework for parsing and generating JSON documents under the terms of a developer friendly Apache License, Version 2.0.

Status: Beta *)

The implementation details are implemented in C++. There is also a fully functional C++ API with a STL compatible JSON representation, which offers superior performance. The C++ API status is Alpha, though.

You can view the online Documentation for the Objective-C API at http://couchdeveloper.github.com/JPJson/.

Basic Features

Possible Improvements

*) Due to its Beta status, not all minor features are implemented in this version. Well, the feature might actually be there and may be well tested, but a higher level function may not actually use it, or the higher level API simply does not make it public.

The following features are not yet implemented, but planned in one of the next beta version:

Not Yet Implemented

Known Bugs

("Known bugs" are subject to be fixed in the next version.)

Notes For Developers

The library is designed for flexibility. It is devided into several independent sub-modules and utility classes, each comming with its own unit tests and benchmark tests.

The implementation has been rigorously fine-tuned for performance and low memory foot-print. Internally, it's implemented using C++11 and utilizes the standard C++11 library and the boost library when appropriate.

The performance of the Objective-C API is comparable to the currently fastest available Objective-C implementation (JSONKit). However, the JPJsonParser can be used to simultaneously download and parse JSON text of arbitrary size, and thus is cleary superior in those scenarios, escpecically on hardware with more than one CPU.

Included in the package are sample projects showing the basic and advanced usage, unit tests, benchmark tests, library and framework projects, and more complete iOS projects showing how to download and parse a very large JSON text without exceeding restricted memory. Additionaly, there is an AppleDoc build phase for generating the Objective-C API help documents.

Design

On a higher level, there is the "JSON Parser", the "JSON Writer" and the "Semantic Actions", which will be explained briefly. The C++ API also contains a nice and fast implementation for the JSON representation with an STL like interface.

These high level modules use common support moduls and utility classes. For instance there is a separate Unicode conversion library, a byte-swapping module, synchronization primitives, logger modul, string-hasher, base64 decoder/encoder, an experimental json-path module and more.

The parser is actually devided into two parts: the "core parser", whose purpose is to solely parse JSON text and sending "parser events" with associated JSON data and further info when encountering the many different parts of a JSON text.

The second part is the "Semantic Actions". The Semantic Actions is a class whose purpose is to act on the parser events. This class can be customized, aka subclassed, which allows to do virtually anything when parsing a JSON document.

In an advanced application, the developer pairs the JSON Parser with a "Semantic Actions object", either a "biult-in" one or one that has been customized for special needs in order achieve the desired behavior without the need to reimplement many parts of the library.

One of the "builtin" Semantic Actions object creates a representation of a JSON text which is a hierarchy of Foundation objects and is the default in the "convenience interface".