JAPY is a new json parser in C++.
JAPY is yet another json path (and parser) thing, written in C++ (currently - C++11). It has some unusual features:
- Stream parsing - if you are consuming, say, Twitter's json streams, japy is for you.
- Path language, allowing you to make complex traversals through the json document with a single 'expression'.
- Easy to use and efficient (not yet that much, but will soon become).
Japy is free, use it however you like (see LICENSE for details).
Japy has no dependencies (other than some STL), just grab japy.hpp and go. For examples of use, see examples.cpp. Your feedback will be very much appreciated.
And here is what japy path language is:
example:
array:/object:/array:some_name//!array:/?integral:another_name
abbreviated:
#/$/#some_name//!#/?i:another_name
Path consists of selectors. Selectors are separated by '/'.
Selectors may contain any or all of these, in this order:
/
- to mean 'recursive' (match not only children, but all descendants)!
- to mean 'inverse' (select nodes that do not match the selector)?
- to mean 'optional' (don't throw exceptions if selector does not match)- type - to specify type of node:
*
orany:
- any type#
or#:
orarray:
- array$
or$:
orobject:
- object@
or@:
orvalue:
- anything except#
and$
i:
orintegral:
- integral valuesf:
orfloat:
- floating-point valuesb:
orboolean:
- boolean value (true or false)n:
ornull:
- nulls:
orstring:
- string
name
- name of node if it is a member of object (or quoted "name" if you want to use symbols other than a-zA-Z0-9 and -_).
Leading /
means that first selector is matched against the root.
Absence of leading /
means that first selector is matched against children.
That's it. Take a look at examples.cpp to see how it works.
UP: I have recently discovered a node.js module JSONStream built on pretty much the same principles as Japy. If you care, of course.
Copyright © 2014, Artur Brugeman, [email protected].