Aug. 9, 2019
5:53 p.m.
Rhodri James wrote:
I get what you want -- "this string of digits is the representation I want to use, please don't put quotes around it" -- but I can't help but feel that it will only encourage more unrealistic expectations.
I think "consenting adults" applies here. Yes, you could use it to produce invalid JSON, so it's your responsibility to not do that. And if you do so accidentally, you'll find out about it when other things (and quite possibly your own thing) fail to read it. If you really insist on being strict, it could require you to return a special wrapper type that takes a string of digits and checks that it conforms to the syntax of a JSON number. Come to think of it... you could use Decimal as that wrapper type! -- Greg