1 json->string
# -*- coding: utf-8 -*-
import json
student = {"id":"123", "name":"122", "age":18}
print(type(student))
print(student)
print('-'*10)
result = json.dumps(student)
print(type(result))
print(result)
2 string->json
2.2 json类
import json
str = '{"key": "wwww", "word": "qqqq"}'
j = json.loads(str)
print(j)
print(type(j))
2.1 ast类
import ast
a = "{1: 'a', 2: 'b'}"
b = ast.literal_eval(a)
type(b)
dict