Passing in a malformed JSON string results in a JavaScript exception being thrown. For example, the following are all invalid JSON strings:
"{test: 1}"
(test does not have double quotes around it)."{'test': 1}"
('test' is using single quotes instead of double quotes)."'test'"
('test' is using single quotes instead of double quotes).".1"
(a number must start with a digit;"0.1"
would be valid)."undefined"
(undefined
cannot be represented in a JSON string;null
, however, can be)."NaN"
(NaN
cannot be represented in a JSON string; direct representation ofInfinity
is also not permitted).
0 comments:
Post a Comment