Home > other >  Questions about json transfers
Questions about json transfers

Time:04-08

Problem a: list [object] into a json
The class Employee:

Aaa=""
BBB=""
CCC=""
DDD=""


=======================
Import the test
The import json

ABC=[]

Aaa=test. The Employee ()
BBB=test. The Employee ()

Aaa. Aaa="a1"
Aaa, BBB="b1"
Aaa. CCC=14

BBB. Aaa="a11"
BBB. CCC="c11"
BBB. DDD=36

ABC. Append (aaa)
ABC. Append (BBB)

Print (json. Dumps (ABC))

TypeError: the Object of type Employee is not a JSON serializable

==================================================
Question 2, is there any way to dict + object into a list

{" a1 ": 1," a2 ": 2} {" b1" : 1, "b2" : 2} + object into a list
  • Related