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.
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.
@atoponce ...why would that be valid? You're inlining code, the whole point of JSON is that it doesn't need to evaluate code.
@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.
@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.
@atoponce What really irritates me about JSON is it doesn't support undefined, Infinity, -Infinity, or NaN.
@ekis As a mathematician, I want real numbers. 1/6 is a real number, but in programming languages, it's an operation instead. This triggers my OCD.
@atoponce Why should it? You would be including an operator.
"operators are constructs defined within programming languages which behave generally like functions"
You would not want logic in JSON, one of the downsides would be security.
```
{
"n": [
0,
0.166666666667,
2
]
}
```
Is no good? Also, if it did work, I'd expect it to require parenthesis.
GNU social JP is a social network, courtesy of GNU social JP管理人. It runs on GNU social, version 2.0.2-dev, available under the GNU Affero General Public License.
All GNU social JP content and data are available under the Creative Commons Attribution 3.0 license.