1

When I do:

merchant = Merchant.query.all()
data = json.dumps(merchant)
data = json.load(data)

This is my queried result:

company: Rajendra | agent: None | user: zxnGiCqSPl | fullname: CtwrXsGVQZOSEwZtbYTrTkPTDjY | dob : 1989-12-12 | idproof: | mobile: 8874565109 | email : PuMGDmu@aasaanpay.com | bankName: KOTAK | ifsc: KOTAK5064960 | acNumber: 5696245574 | MDR_Debit: 0.73 | MDR_Credit: 0.96 | MDR_CreditGold : 1.01 | address1: Vindhya C5-222 | address2: OBH | city: Hyderabad | district: Hyderabad | state: statethree | pincode: 677514

rajendra lora
  • 21
  • 1
  • 2

1 Answers1

2

Just put the data into a dictionary and dump the dictionary, or am I missing something:

data = {
    'company': merchant.company,
    'agent': merchant.agent,
    'user': merchant.user,
    'fullname': merchant.fullname
    'dob': merchant.dob
    ...
}
jsonified_data = json.dumps(data)

And use json.loads when loading a JSON string.

json.loads(jsonified_data)
Will
  • 453
  • 4
  • 8