<div dir="ltr">I think you are looking for this nice parse transform:<div><br></div><div><a href="https://github.com/bossek/embjson">https://github.com/bossek/embjson</a><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jun 15, 2015 at 7:07 PM, Thomas Elsgaard <span dir="ltr"><<a href="mailto:thomas.elsgaard@gmail.com" target="_blank">thomas.elsgaard@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi list<div><br></div><div>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 ?</div><div><br></div><div>Here is the code:</div><div><br></div><div>Method = patch,</div><div>URL = <<"<a href="http://2.2.2.2:8081/servers/localhost/zones/xxx.gl" target="_blank">http://2.2.2.2:8081/servers/localhost/zones/xxx.gl</a>">>,</div><div>Headers = [{<<"X-API-Key">>, <<"xxxxxxxx">>}],</div><div>Payload = <<"{\"rrsets\":[{\"name\": \"<a href="http://xxx.gl" target="_blank">xxx.gl</a>\",\"type\": \"A\",\"changetype\": \"REPLACE\",\"records\": [{\"content\": \"1.1.1.1\",\"disabled\":false,\"name\": \"<a href="http://xxx.gl" target="_blank">xxx.gl</a>\",\"ttl\": \"3600\",\"type\": \"A\",\"priority\": \"0\"}]}]}">>,</div><div>Options = [],</div><div>{ok, StatusCode, RespHeaders, ClientRef} = hackney:request(Method, URL, Headers, Payload, Options). </div><div><br></div><div>Any hints so that it looks nice ;-)</div><span class="HOEnZb"><font color="#888888"><div><br></div><div>Thomas</div></font></span></div>
<br>_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" rel="noreferrer" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
<br></blockquote></div><br></div>