Thursday, January 18, 2018

python flask json jsonify convert json string object

from flask import jsonify, json
try:
# Initialize a employee list
employeeList = []

# create a instances for filling up employee list
for i in range(0, 2):
empDict = {
'firstName': 'Roy',
'lastName': 'Augustine'
}
employeeList.append('adsf')

# convert to json data
jsonStr = json.dumps(employeeList)
jsonObj = json.loads(jsonStr)
print(jsonObj)
# print(jsonify(Employees=jsonStr))
except Exception as e:
print(str(e))

No comments: