2 ms·
`str` is the equivalent of `toString`, not of `JSON.stringify`. Failure of a serializer-deserializer to roundtrip properly is corruption. The poorly chosen name
by mike_hock 3y ago
`str` is the equivalent of `toString`, not of `JSON.stringify`. Failure of a serializer-deserializer to roundtrip properly is corruption. The poorly chosen name (which is usually called "dump" or "serialize" in other languages) does not give license for silent corruption.
- jay_kyburz 3y ago"stringify" sound more like toString than serialize to me.
- anamexis 3y agoI think that is the issue.
- baq 3y agoI agree with everyone here: it’s named correctly, but other languages did it… differently. (Stopping short of “better”, but only just.)
- randomdata 3y agoThat is the solution. It allows JSON.serialize to exhibit the non-corrupting behaviour, giving a reasonable indication to the developer which is which by the name alone. The issue, if there is one, is that nobody ever got around to implementing JSON.serialize.
- accrual 3y agoIf a JSON.serialize function did exist, would it do the same thing as JSON.stringify, just with catchable exceptions when one tries to serialize something that can't be (e.g. functions, date objects)?