According to the 2019 Chrome Dev Summit video, "Faster apps with JSON.parse", using JSON.parse
with a string literal instead of declaring the json through an object literal results in a noticeable speed improvement. The google JSON.parse benchmarks show a major difference between the two.
//JS object literal
const data = { foo: 42, bar: 1337 }; //
//JSON.parse 20%+ faster
const data = JSON.parse('{"foo":42,"bar":1337}'); //
When declaring json in javascript, are there any downsides of using JSON.parse
instead an object literal? Should json always be declared using the JSON.parse?