4 ms·
You don't think JSON should be validated in production? Presumably you think you should always be able to trust anyone who sends you JSON? I mean Go already d
by ncruces 3y ago
You don't think JSON should be validated in production?
Presumably you think you should always be able to trust anyone who sends you JSON?
I mean Go already does a bunch of UTF-8 validations in its JSON encoder/decoder [1]. No need to make those faster.
[1] https://pkg.go.dev/encoding/json#Marshal https://pkg.go.dev/encoding/json#Marshal
- Dylan16807 3y agoHi, what? I said hypothetical, and I did not use the word JSON.
- ncruces 3y agoBoth JSON encoding and decoding require UTF-8 validation. If there's a workload that makes sense to optimize because it's used in production, it's UTF-8 validation. So why are we even arguing whether UTF-8 validation is necessary/useful in the "hot path" or in "production"?
- Dylan16807 3y agoSo you asked what I thought, but I never gave an opinion on UTF-8, I gave a generic hypothetical. If you're asking about OP's idea, then I agree that validating the UTF-8 inside of JSON is needed sometimes, though it's not required in all situations. But I wasn't commenting on that, I was commenting on the specific objection of "how do you know if you don't check?", because I don't think that specific objection is very strong.