talentdeficit / jsx

an erlang application for consuming, producing and manipulating json. inspired by yajl
MIT License
694 stars 217 forks source link

How i can Insert RAW data? #119

Open loguntsov opened 6 years ago

loguntsov commented 6 years ago

Hello.

This is not issue but just question. Is there way to insert RAW data into encoded json ? As example: I have valid JSON-string: "{'a':1}" (it can be big string) i would want insert this string as JSON: {'key':{'a':1}}. I don't want decode/encode string twice, i just want insert this string to get resulted JSON as above. Is there way for this ?

I imagine this way like this: jsx:encode([{raw, key, "{'a':1}"}])

Thank you.

talentdeficit commented 6 years ago

you can use raw like: jsx:encode([{<<"key">>, {raw, "{\"a\":1}"}]) but it's not particularly efficient. it's equivalent to jsx:encode([{<<"key">>, jsx:decode("{\"a\":1}")]) more or less

loguntsov commented 6 years ago

i don't like it

loguntsov commented 6 years ago

Can i develop this logic jsx:encode([{raw, key, <<"{'a':1}">>}]) to make best way for my purpose ? Will this pull request be merged with upstream ?

paulo-ferraz-oliveira commented 4 years ago

Is this still a valid concern? I seem to want something similar, but this issue went nowhere.