[erlang-questions] fast JSON parser in C
Wed Jul 23 02:09:06 CEST 2008
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.
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.
[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:
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?
erlang-questions mailing list
More information about the erlang-questions