jaxon icon indicating copy to clipboard operation
jaxon copied to clipboard

JSON encoding

Open boudra opened this issue 5 years ago • 2 comments

  • Take an Erlang term and convert it into JSON events
  • Take a list of events and encode into a JSON string representation

boudra avatar Jul 28 '18 13:07 boudra

Hi, I'm the writer of https://github.com/TreyE/json_stream_encoder. I was wondering if you might be looking for something like this. It's a simple encoder whose main winning point is not needing the entire Erlang/Elixir term to be in memory. The license is MIT as well, so if you find it useful you might want to just steal it or some of its very simple ideas (with my blessing).

I've been mainly using it to stream encoding of huge sets of SQL records to an IOish item - it may not suit your use case but hopefully it provides some helpful starting places that might save you some time.

TreyE avatar Dec 26 '18 16:12 TreyE

Hi @TreyE, thanks, should be helpful!

This is how I was thinking encoding would work:

iex> Jaxon.Encoder.term_to_events(%{"key" => true})
[:start_object, {:string, "key"}, :colon, {:boolean, true}, :end_object]

iex> Jaxon.Encoder.encode([:start_object, {:string, "key"}, :colon, {:boolean, true}, :end_object])
"{\"key\":true}"

boudra avatar Jan 02 '19 11:01 boudra