Skip to content

brugeman/japy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JAPY

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:

  1. Stream parsing - if you are consuming, say, Twitter's json streams, japy is for you.
  2. Path language, allowing you to make complex traversals through the json document with a single 'expression'.
  3. 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:
    • * or any: - any type
    • # or #: or array: - array
    • $ or $: or object: - object
    • @ or @: or value: - anything except # and $
    • i: or integral: - integral values
    • f: or float: - floating-point values
    • b: or boolean: - boolean value (true or false)
    • n: or null: - null
    • s: or string: - 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, brugeman.artur@gmail.com.

About

JAPY is a new json parser in C++

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages