[erlang-questions] fast JSON parser in C
Jonathan Gray
jlist@REDACTED
Wed Jul 23 02:09:06 CEST 2008
Chris,
I'm currently using something just as you are describing. I have
erl_to_json() and json_to_erl() functions in C which convert ETERM -> JSON
and JSON -> ETERM. Both are recursive C functions which make use of
erl_eterm from erl_interface.
The erl_interface library allows you to construct all the Erlang term types
in C, marshall/encode them, and pass them off directly to Erlang.
http://www.erlang.org/doc/apps/erl_interface/ref_man_erl_interface_frame.htm
l
Beware: I just posted to erlang-bugs an issue I'm having with this. It
works just fine for smaller sizes, but we're having an issue crop up when we
attempt to unmarshall/decode a large ETERM in C using erl_decode() from
erl_interface. It is a reproducible "bug" as the problem only exists in C
using erl_interface, Erlang has no issues with it at all.
Hope that helps.
Jonathan Gray
Streamy Inc.
-----Original Message-----
From: erlang-questions-bounces@REDACTED
[mailto:erlang-questions-bounces@REDACTED] On Behalf Of Chris Anderson
Sent: Tuesday, July 22, 2008 4:30 PM
To: Erlang Questions
Subject: [erlang-questions] fast JSON parser in C
I'm considering wrapping one of the many fast JSON parsers written in
C, using the Erlang FFI. I'm still just learning how the pieces fit
together - got to hello world via this tutorial:
http://www.wagerlabs.com/blog/2008/02/erlang-ffi---in.html
The first hurdle I've found is that it might not be all the efficient
to use C for a JSON parser, as the communication between Erlang and C
function is limited to buffers. If communication is essentially
limited to strings, I'll end up writing a parser in Erlang for
whatever I concoct on the C side... so I may be better off working to
speed up some of the existing pure Erlang JSON parser implementations.
But perhaps I'm missing something. Is there a way to construct complex
Erlang data structures (nested tuples and lists, with binary, atom,
integer and float components) directly inside C, and then return the
constructed object to Erlang where it can do things like participate
in pattern matchers, etc?
Thanks!
Chris
--
Chris Anderson
http://jchris.mfdz.com
_______________________________________________
erlang-questions mailing list
erlang-questions@REDACTED
http://www.erlang.org/mailman/listinfo/erlang-questions
More information about the erlang-questions
mailing list