3 ms·
JSON is a text format that looks like a JavaScript Object when it (the object) is in text form. It has nothing to do with its memory layout. It's just a name.
by 0x457 4y ago
JSON is a text format that looks like a JavaScript Object when it (the object) is in text form. It has nothing to do with its memory layout. It's just a name.
The actual object in memory has to be serialized/deserialized to/from JSON.
ECMA-404 (the standard for JSON) allows values that cannot be possible represented in JavaScript - integers and float bigger than 53 bits; At the same time, it forbids totally legal JavaScript's NaN and Infinity.
JavaScript is faster and JSON because any modern JS VM is a lot faster than Ruby VM. If JSON didn't require serialization/serialization, it would be inherently unsafe at any speed.
: There are ways to handle exchange without serialization and serialization safely, but you're suggesting is that memory that holds json text is just cast to json object.