> js does not need to de/serialized its own native format
This doesn’t make any sense. JSON is a string. Converting a Ruby array or hash to or from a string is exactly the same work as converting a JS array or object to or from a string.
Individual implementations may be better in JS, but there’s no inherent reason for that.
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.