2 ms·
Native parsing is a red herring; even in the bad old days, it was quick enough to be unnoticeable unless you were working on Big Data in the browser. Moving to
by Millennium 14y ago
Native parsing is a red herring; even in the bad old days, it was quick enough to be unnoticeable unless you were working on Big Data in the browser. Moving to native-code parsing for the sake of performance is a major case of premature optimization.
JSON's big advantage was that you didn't have to do any work. One function call, with a single argument, would take you from a blob of text to a fully populated data structure, and that function was already built into every browser. The name of the function has changed (eval() to JSON.parse()), and some genuine security enhancements went with that, but the form of the API hasn't, and there's a reason for that: anything more than one monadic function call is too much work.
Some formats, like TOML, have gone so far as to explicitly specify the data structure they describe. You could make a no-work API like JSON's for that: TOML.parse() and TOML.stringify() would take up more code space than their corresponding JSON APIs, but using the APIs would still involve no work. Less work, in fact, because TOML has a date literal, which even JSON doesn't. Something like that could catch on.