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 : [email protected] | 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

3
  • 3
    I hope that is dummy data. Commented Dec 21, 2015 at 10:03
  • yes this is dummy data for testing purpose. #jamie bull Commented Dec 21, 2015 at 10:20
  • that result is not working in my case can you please elaborate it more #rmn Commented Dec 21, 2015 at 10:21

1 Answer 1

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)
Sign up to request clarification or add additional context in comments.

1 Comment

I used your concept and created a serialiser function in models and it return dictionary. So it works now. thanks

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.