This should be valid JSON:
-
This should be valid JSON:
{
"n": [0, 1/6, 2]
}But alas:
"Invalid JSON!
Error: Parse error on line 2:
{ "n": [0, 1/6, 2]}
-------------^
Expecting 'EOF', '}', ',', ']', got 'undefined'"Ugh.
-
Ryan Castellucci :nonbinary_flag:replied to Aaron Toponce ⚛️:debian: last edited by
@atoponce ...why would that be valid? You're inlining code, the whole point of JSON is that it doesn't need to evaluate code.
-
Aaron Toponce ⚛️:debian:replied to Ryan Castellucci :nonbinary_flag: last edited by
@ryanc Yeah, I guess. 1/6 is a number though just as much as 0.16666666666666666. I guess I could do:
{
"n": [0, {"/": [1, 6]}, 2]
}And handle the operation in my code, but that's annoying.
-
Ryan Castellucci :nonbinary_flag:replied to Aaron Toponce ⚛️:debian: last edited by
@atoponce In what programming languages is 1/6 a number and not code? Exact fractions (BigRational?) are a nice thing to have for some use cases, but I don't think many languages have them out of the box.
-
Ryan Castellucci :nonbinary_flag:replied to Ryan Castellucci :nonbinary_flag: last edited by
@atoponce What really irritates me about JSON is it doesn't support
undefined
,Infinity
,-Infinity
, orNaN
.