Answer the question
In order to leave comments, you need to log in
Why does json.load consider the textual representation of digits to be valid json?
>>> json_object = json.loads("60")
>>> json_object
60
json.loads(60) is an error, json.loads("aa") is an error, but json.loads("60") is no error does not give out, and I cannot distinguish json from a string with numbers. Two questions:
1) Why is that?
2) How to distinguish json from a number if I received a text string?
Answer the question
In order to leave comments, you need to log in
Obviously a literal "60"
is a string 60
. String 60
is json from number 60
.
Json for a string аа
is a string "аа"
, and a literal for such a string would be "\"аа\""
.
As data in memory, by itself, pure strings are stored, so you will not have problems with data coming from outside.
according to the standard , json is a constant in javascript format, which just fall under numbers
value = false / null / true / object / array / number / string
Regarding the first question from the wiki :
The following can be used as values in JSON:
{"hasBrain": false", "name": "Zombie"}
[1, 2, "a", 7, true, {"a": "b"}]
-11.2
true
(boolean true), false
(boolean false), and null."asdasd"
"60"
- this is point 5 aa
- this is none of the points. Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question