sinasamavati / leptus

The Erlang REST framework
https://sinasamavati.com/leptus
MIT License
346 stars 50 forks source link

optional jiffy encode #54

Closed tommyjcarpenter closed 8 years ago

tommyjcarpenter commented 8 years ago

I have an external process that returns to me a proper JSON (call it R) as a binary:

R = some_func(),
erlang:display(R),
{200, {json, R}, State}

displays

<<"{\"fulllist\": \"True\"}">>

However, using the code above, what actually gets returned to the client looks like the above, because it is doubly encoded because I think you always call jiffy:encode. So what the client actually gets is:

<<"{\"fulllist\": \"True\"}">>

I would like to request an optional "do not reencode" flag somehow.

As a hack, for now, what I am doing is calling a decode first since it gets reencoded:

R = ...
erlang:display(R),
V = jiffy:decode(R),
{200, {json, V}, State}
returns
{"fulllist":"True"}