JSON decoding

Brendan Eich brendan at mozilla.org
Fri Oct 20 13:43:10 PDT 2006

On Oct 20, 2006, at 4:35 PM, Bob Ippolito wrote:

> On 10/20/06, Brendan Eich <brendan at mozilla.org> wrote:
>> On Oct 20, 2006, at 4:11 PM, Bob Ippolito wrote:
>> > The encoder should have an object hook the same way the decoder  
>> does.
>> Symmetry, what a good idea.  TG1 members should consider this  
>> seriously.
>> > Throw away the filter.
>> There was some desire to filter without copying.
> What was the use case for filtering? I've never seen anyone do that.

The use case is taking a vanilla object that may have ad-hoc  
properties that should not be serialized.  The filter could be used  
to whitelist or blacklist properties.

>> > Filtering functionality can be implemented if necessary by  
>> writing an
>> > encoder hook that inspects the object. If it needs to remove some
>> > key:value pairs, then it would create a new object that is  
>> missing the
>> > keys that should be filtered.
>> That's the copy we hoped to avoid.  Not a problem in your simplejson
>> experience?
> Not a problem because I've never seen anyone perform such a filter. If
> the output needs to differ from the input it's usually based on the
> *value* not the key:value pair. When the encoding needs to differ it's
> usually not strict subset of the input, but a different object
> altogether.

Ok, good feedback.  TG1 (or at least yours truly) will take it to heart.


More information about the Es4-discuss mailing list