std.data.json formal review

Sönke Ludwig via Digitalmars-d digitalmars-d at puremagic.com
Tue Aug 11 14:21:45 PDT 2015


Am 11.08.2015 um 20:15 schrieb Dmitry Olshansky:
> On 11-Aug-2015 20:30, deadalnix wrote:
>>
>> Ok some actionable items.
>>
>> 1/ How big is a JSON struct ? What is the biggest element in the union ?
>> Is that element really needed ? Recurse.
>
> +1 Also most JS engines use nan-boxing to fit type tag along with the
> payload in 8 bytes total. At least the _fast_ path of std.data.json
> should take advantage of similar techniques.

But the array field already needs 16 bytes on 64-bit systems anyway. We 
could surely abuse some bits there to at least not use up more for the 
type tag, but before we go that far, we should first tackle some other 
questions, such as the allocation strategy of JSONValues during parsing, 
the Location field and BigInt/Decimal support.

Maybe we should first have a vote about whether BigInt/Decimal should be 
supported or not, because that would at least solve some of the 
controversial tradeoffs. I didn't have a use for those personally, but 
at least we had the real-world issue in vibe.d's implementation that a 
ulong wasn't exactly representable.

My view generally still is that the DOM representation is something for 
convenient manipulation of small chunks of JSON, so that performance is 
not a priority, but feature completeness is.


More information about the Digitalmars-d mailing list