yajl (original) (raw)
Overview
Yet Another JSON Library. YAJL is a small event-driven (SAX-style) JSON parser written in ANSI C, and a small validating JSON generator. YAJL is released under the ISC license.
Documentation
Documentation generated by doxygen from source is available for v2.1.0, and for the previous stable release: v1.0.12.
Code
Get it on github: http://github.com/lloyd/yajl
Support
You can find Yajl on IRC in the #yajl channel on the Freenode network or you can subscribe to the Yajl mailing list by sending an email toyajl@librelist.com (more info on Librelist here)
Download
- yajl-2.1.0.zip
- yajl-2.1.0.tar.gz
- yajl-1.0.12.zip
- yajl-1.0.12.tar.gz
- yajl-master.zip
- yajl-master.tar.gz
You can also clone the project with Git by running:
$ git clone git://github.com/lloyd/yajl
Features
Simple Interface
Largely because YAJL is event driven, the interface is very concise object oriented C. The interface is not cluttered with data representation, that bit is left up to higher level code. Indeed it should be possible to port most existing JSON libraries onto YAJL if so desired.
portable
It's all ANSI C. It's been successfully compiled on debian linux, OSX 10.4 i386 & ppc, OSX 10.5 i386, winXP, FreeBSD 4.10, FreeBSD 6.1 amd64, FreeBSD 7 i386, and windows vista. More platforms and binaries as time permits.
Stream parsing
YAJL remembers all state required to support restarting parsing. This allows parsing to occur incrementally as data is read off a disk or network.
Fast
A second motivation for writing YAJL, was that many available free JSON parsers fall over on large or complex inputs. YAJL is careful to minimize memory copying and input re-scanning when possible. The result is a parser that should be fast enough for most applications or tunable for any application. On my mac pro (2.66 ghz) it takes 1s to verify a 60meg json file. Minimizing that same file with json_reformat takes 4s.
Low resource consumption
Largely because YAJL deals with streams, it's possible to parse JSON in low memory environments. Oftentimes with other parsers an application must hold both the input text and the memory representation of the tree in memory at one time. With YAJL you can incrementally read the input stream and hold only the in memory representation. Or for filtering or validation tasks, it's not required to hold the entire input text in memory.
sample programs
included in the source are a couple sample programs to demonstrate and test yajl:
json_reformat: a minimizer and beautifier in one.
json_verify: a JSON verifier.
comments in JSON
If you're dead set on using JSON throughout your system, you'll probably end up using it for your configuration files too. A little crazy, perhaps. But so am I. At parser allocation time you may specify a configuration parameter to allow comments inside the JSON input text. This is supported in versions 0.2.0 and above.
Example Programmatic Usage In C
License
Copyright (c) 2007-2011, Lloyd Hilaiel lloyd@hilaiel.com
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. /lloyd@hilaiel.com
Related projects
- yajl-ruby - ruby bindings for YAJL
- yajl-objc - Objective-C bindings for YAJL
- YAJL IO bindings (for the IO language)
- Python bindings come in two flavors, py-yajl OR yajl-py
- yajl-js - node.js bindings (mirrored to github).
- lua-yajl - lua bindings
- ooc-yajl - ooc bindings
- yajl-tcl - tcl bindings
- JSON-YAJL - perl bindings
- yajl-d - D bindings for YAJL
Contributors
Many people have helped hone yajl to a fine edge, they have my deep appreciation for taking the time to give back. Here they are in alphabetical order (if I missed anyone, please tell me. It's been a while and my memory is bad):
- Adam McLaurin
- Andrei Soroker
- Artem S Vybornov (@vibornoff)
- Bobby Powers (@bpowers)
- Mr. Baptiste (@bapt)
- Brian Lopez (@brianmario)
- Brian Maher (@brimworks)
- Conrad Irwin (@ConradIrwin)
- Daniel P. Berrange
- Eric Bergstrome
- Florian Forster (@octo)
- Greg Olszewski (@gno)
- Hatem Nassrat
- John Stamp (@jstamp)
- Karl Adam (@thekarladam)
- Karl Lehenbauer
- Mark de Does
- Michael Hanson (@michaelrhanson)
- Mirek Rusin (@mirek)
- Neville Franks
- R. Tyler Croy (@rtyler)
- Randall E. Barker (@bluemarvin)
- Rick (@technoweenie)
- Robert Geiger
- Robert Varga
- Timothy J. Wood
- Vitali Lovich
Original Author
Lloyd Hilaiel (lloyd 4t hilaiel d0t com)