TypeError: Object of type 'Column' is not JSON serializable

Viewed 595

TypeError: Object of type 'Column' is not JSON serializable

What could this error possibly mean ?

test_respnse is a Json file which I am trying to convert into a dictionary.

 test_response = json.dumps(test_response)

Contents of test_response :

{
   "req_type":1,
   "date":"2021-02-21",
   "team1":{
      "name":"Everton FC",
      "player1":"Chris Gunter",
      "player2":"Matteo Darmian",
      "player3":"Ragnar Klavan",
      "player4":"Jan Vertonghen",
      "player5":"Joshua King",
      "player6":"Jordan Ayew",
      "player7":"Charlie Austin",
      "player8":"Simon Mignolet",
      "player9":"Stefano Sensi",
      "player10":"Samuel Bastien",
      "player11":"Gareth Barry",
   },
   "team2":{
      "name":"Crystal Palace FC",
      "player1":"Vincent Kompany",
      "player2":"Kieran Trippier",
      "player3":"Trent Alexander-Arnold",
      "player4":"Ben Davies",
      "player5":"Eddie Nketiah",
      "player6":"Lukas Nmecha",
      "player7":"Michael Obafemi",
      "player8":"Hugo Lloris",
      "player9":"Victor Moses",
      "player10":"Rolando Aarons",
      "player11":"Dean Whitehead",
   }
}
1 Answers

The current Json looks like

{
   "req_type":1,
   "date":"2021-02-21",
   "team1":{
      "name":"Everton FC",
      "player1":"Chris Gunter",
      "player2":"Matteo Darmian",
      "player3":"Ragnar Klavan",
      "player4":"Jan Vertonghen",
      "player5":"Joshua King",
      "player6":"Jordan Ayew",
      "player7":"Charlie Austin",
      "player8":"Simon Mignolet",
      "player9":"Stefano Sensi",
      "player10":"Samuel Bastien",
      "player11":"Gareth Barry",
   },
   "team2":{
      "name":"Crystal Palace FC",
      "player1":"Vincent Kompany",
      "player2":"Kieran Trippier",
      "player3":"Trent Alexander-Arnold",
      "player4":"Ben Davies",
      "player5":"Eddie Nketiah",
      "player6":"Lukas Nmecha",
      "player7":"Michael Obafemi",
      "player8":"Hugo Lloris",
      "player9":"Victor Moses",
      "player10":"Rolando Aarons",
      "player11":"Dean Whitehead",
   }
}

There is an extra comma present after the last data item i.e. the 11-th player of the "team1" and "team2". Thus if we remove the comma, the error gets resolved since the Json is syntactically now.

After removal ths Json looks like:

{
   "req_type":1,
   "date":"2021-02-21",
   "team1":{
      "name":"Everton FC",
      "player1":"Chris Gunter",
      "player2":"Matteo Darmian",
      "player3":"Ragnar Klavan",
      "player4":"Jan Vertonghen",
      "player5":"Joshua King",
      "player6":"Jordan Ayew",
      "player7":"Charlie Austin",
      "player8":"Simon Mignolet",
      "player9":"Stefano Sensi",
      "player10":"Samuel Bastien",
      "player11":"Gareth Barry"
   },
   "team2":{
      "name":"Crystal Palace FC",
      "player1":"Vincent Kompany",
      "player2":"Kieran Trippier",
      "player3":"Trent Alexander-Arnold",
      "player4":"Ben Davies",
      "player5":"Eddie Nketiah",
      "player6":"Lukas Nmecha",
      "player7":"Michael Obafemi",
      "player8":"Hugo Lloris",
      "player9":"Victor Moses",
      "player10":"Rolando Aarons",
      "player11":"Dean Whitehead"
   }
}
Related