4 ms·
IIRC, JSON is a strict subset of JS and Python.
by hrjet 13y ago
IIRC, JSON is a strict subset of JS and Python.
- riffraff 13y agois it? "null" is not valid python, I think
- mercurial 13y agoIt isn't. It would be None. I believe parent is mistaken.
- hrjet 13y agoI stand corrected; I am not that familiar with python. Though I remember reading somewhere that JSON can be evaled in both JS and Python. Perhaps the python bit is not true.
- kibibu 13y agoJSON looks more-or-less like a Python dict, but you still wouldn't be able to parse {"x": NaN} or {"x": Infinity}
- derefr 13y agoOddly, there's actually no language that I know of that has NaN and Infinity constants. Many languages pretty-print those float values that way, but none of the parsers can interpret them back in.
- GeneralMayhem 13y ago...do you mean other than JavaScript? They're not actually parser-level constants, they're just defined as globals/on the window object, but they work.
- wisty 13y agoIf you do this first: null = None Infinity = float('Infinity') NaN = float('nan') (But no, it's not quite Python)
- adambard 13y agoI have never heard anyone else make this assertion.
- mcv 13y agoThe Python is new to me, but JSON's strong relationship to javascript is not new at all: http://en.wikipedia.org/wiki/JSON http://en.wikipedia.org/wiki/JSON
- pnachbaur 13y agoJSON originated from Javascript alone