jsx icon indicating copy to clipboard operation
jsx copied to clipboard

nested raw json for encoder

Open zmstone opened this issue 8 years ago • 3 comments

Hi There!

Is it possible to have a inner part of an object encoded already, and jsx takes the inner part 'as is' when encoding the wrapping object ? like https://github.com/tophitpoker/mochijson3/blob/master/src/mochijson3.erl#L111

It seems the equivalent in jsx is {'raw', binary()} https://github.com/talentdeficit/jsx/blob/develop/src/jsx_parser.erl#L110 But the 'Raw' json is decoded there, then encoded back again later on. Is this to validate the raw part ?

What do you think if I add a {json, TrustedRaw} clause (or a trust_raw encoder config) ?

zmstone avatar Jun 18 '16 07:06 zmstone

a trusted raw option would still have to be decoded because of the way jsx works internally.

all the valid input types are parsed into an AST that is then consumed by handlers. it would be possible to add a raw type to the AST but that would break all existing handlers so it would have to be in a 3.0 version

talentdeficit avatar Jul 22 '16 17:07 talentdeficit

Hi,

I am actually looking at doing the exact same thing, I am building a json document out of other documents (already validated) and would like to avoid as much overhead as I can.

mpenet avatar Nov 29 '16 09:11 mpenet

This seems more or less related to #119. @talentdeficit: did it make its way to 3.0?

paulo-ferraz-oliveira avatar Sep 12 '20 01:09 paulo-ferraz-oliveira