-2

I have a JSON list that I'm calling from a db, but gets formatted like this:

[('[{"recommendation": "Fung Corp"}, {"recommendation": "AllSeq"}, {"recommendation": "Testing testing org"}]',)]

I want to unnest it so the leading [(' and trailing ,)] so all remains is the actual JSON list of objects

[{"recommendation": "Fung Corp"}, {"recommendation": "AllSeq"}, {"recommendation": "Testing testing org"}]

All in python preferably

Brian Guan
  • 193
  • 2
  • 12
  • This should help:[literal_eval](https://stackoverflow.com/questions/15197673/using-pythons-eval-vs-ast-literal-eval) – AnkurSaxena Feb 02 '21 at 00:30

1 Answers1

0

You can simply do this

db = [('[{"recommendation": "Fung Corp"}, {"recommendation": "AllSeq"}, {"recommendation": "Testing testing org"}]',)]
print(db[0][0])

result,

[{"recommendation": "Fung Corp"}, {"recommendation": "AllSeq"}, {"recommendation": "Testing testing org"}]
Heath
  • 1