python Interface Automation: response content processing json string object

Codes are as follows:

Import JSON
 # define a dictionary, a list of two strings ({} must be double quotes) 
DI1 = { " name " : " badbadboy " , " Age " : " 24 " } 
DI2 = [{ " name " : " badbadboy " , " Age " : " 24 " }] 
DI3 = ' { "name": "badbadboy", "Age": "24"} ' 
DI4 = '[{"name":"badbadboy","age":"24"}]'
#The conversion list / string dictionary for the subject json 
DI5 = json.dumps (DI1) 
DI6 = json.dumps (DI2)
 # convert the string to the list json / dictionary object (if it is in response to the content json string object, available json .loads () process) 
DI7 = json.loads (DI3) 
DI8 = json.loads (DI4)

 

Guess you like

Origin www.cnblogs.com/badbadboyyx/p/12001353.html