4 ms·
The point of JSON is that it is a subset of JavaScript and you could pass it to `eval`.
by sam_lowry_ 3y ago
The point of JSON is that it is a subset of JavaScript and you could pass it to `eval`.
- beardyw 3y agoYes, it is mighty convenient even if JSON is generated by something else to just add a let X = in front and call it js.
- dzsekijo 3y agoI don't see why to stick to being a JavaScript subset. Yes, in the olden days it was practical with JSON that there is no need to write a dedicated parser, just pass the data to eval(). Nowadays you should not pass anything to eval, apart from metaprogramming purposes (in which case the input is fully in control of the code).