[erlang-questions] fast JSON parser in C

Richard A. O'Keefe ok@REDACTED
Mon Jul 28 03:45:03 CEST 2008


On 28 Jul 2008, at 10:48 am, Ulf Wiger wrote:
>
> But with dynamic code loading, you cannot be sure that the atoms
> (presumably created when a given module is loaded) are there
> when the message is decoded. If the message has been decoded
> before a module matching on the decoded term is loaded, the
> labels expected to be atoms may instead be binaries, and it would
> be difficult to know which.


That's easily dealt with:

	ensure_atoms_in_json(Term) ->
	    json_to_term(term_to_json(Term),
		[{label,existing_atom}].

This feature was never meant to be useful with things decoded
before the module that cares was loaded.  This really has nothing
to do with JSON: it's an issue that comes up any time you make
use of list_to_existing_atom/1.









More information about the erlang-questions mailing list