When I opened the json file, it looked like a dictionary by all means. The object classification is different.
dictionary is dic (dictionary) json is str (string) There is a difference. ============================
The data handled by paython is an object, both numbers and letters. You can use the type () function to find out what the variable is.
(input)
a=1
b='python'
c=[1,2,3]
d={'a':1,'b':2}
print(type(a))
print(type(b))
print(type(c))
print(type(d))
(output) class 'int' class 'str' class 'list' lass 'dict'
============================ json can convert list and dic to strings.
c → [1, 2, 3] type → class 'list'
import json json.dumps(c) → '[1, 2, 3]' ※ type(json.dumps(c)) → class 'str'
If it is a string, the list method cannot be used. Why do you do such a troublesome thing?
Since the json format itself is like the standard format (English) when communicating on the Internet, it is not specialized for a specific language, so I think it is worth converting.
Serialize to convert to json format (character string) Deserialize to restore json format (character string) to the original format
Is called.
If you use json.loads, it will return to the original format before conversion.
json.loads(json.dumps(c)) → [1, 2, 3] type(json.loads(json.dumps(c)) ) → 'class 'list'