Erlang/OTP Forums

Author Message

<  User Contributions  ~  efficient json parser

Willem
Posted: Fri Aug 08, 2008 3:20 pm Reply with quote
User Joined: 21 Jul 2006 Posts: 59
json_parser.erl is a parser for json documents.

The parser has a SAX-like API. It also has a mechanism to parse input data in blocks - if it reaches the end of the input data, it will call a function to provide the next block. The combination of these properties results in a parser that can input of arbitrary size, or a stream of data.

Included is a handler function that translates the SAX events into the same output format produced by mochijson2. Looks like this: {struct, [{<<"key1">>, <<"value1">>}, {<<"key2">>, 123}]}.
Interestingly, the new parser (sax parser combined with handler) is roughly 2x as fast as mochijson2 (On my PC, at least).

The parser consists of just 1 file, with some edoc documentation and a couple of very simple examples
included. It only works on UTF-8 encoded input (which implies that it can also parse ASCII, of course).

It can be redistributed under the terms of the GNU Lesser General Public License.

Willem.



json_parser.erl
 Description:
json_parser.erl is an efficient parser for json documents with a SAX-like API.

Download
 Filename:  json_parser.erl
 Filesize:  16.55 KB
 Downloaded:  1427 Time(s)

View user's profile Send private message

Display posts from previous:  

All times are GMT
Page 1 of 1
This forum is locked: you cannot post, reply to, or edit topics.

Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum