[erlang-questions] Store / use JSON structure in an nice way ?

Benoit Chesneau bchesneau@REDACTED
Mon Jun 15 19:27:35 CEST 2015

On Mon, Jun 15, 2015 at 7:07 PM Thomas Elsgaard <thomas.elsgaard@REDACTED>

> Hi list
> I am using hackney as http client (due to PATCH support), and i have an
> JSON structure in the Payload, this works very well, but it is not feeling
> really "good" to have the JSON structure in the code, and i will also need
> to have some variables in the JSON structure instead of only hardcoded
> values. What is the correct erlangish way to handle the JSON payload, is it
> really to have in the code as i have it now, or can it be placed in an
> record ?
> Here is the code:
> Method = patch,
> URL = <<"">>,
> Headers = [{<<"X-API-Key">>, <<"xxxxxxxx">>}],
> Payload = <<"{\"rrsets\":[{\"name\": \"xxx.gl\",\"type\":
> \"A\",\"changetype\": \"REPLACE\",\"records\": [{\"content\":
> \"\",\"disabled\":false,\"name\": \"xxx.gl\",\"ttl\":
> \"3600\",\"type\": \"A\",\"priority\": \"0\"}]}]}">>,
> Options = [],
> {ok, StatusCode, RespHeaders, ClientRef} = hackney:request(Method, URL,
> Headers, Payload, Options).
> Any hints so that it looks nice ;-)
Not sure to fully understand the question but as of today I would use a map
to keep a JSON. Either JSX or Jiffy allow that today.

- benoit

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20150615/961afc25/attachment.htm>

More information about the erlang-questions mailing list