B
B
Brenly2020-10-28 21:26:33
Flask
Brenly, 2020-10-28 21:26:33

How to replace quotes in the received JSON in flask service?

The flask receives json somehow wrong, the application that generates json puts double quotes, and the flask changes them to single quotes. What can be done?

{'create': [{'type': 'simple', 'virtual': True, 'regular_price': '21.99', 'name': 'дрель аккумуляторная 222', 'downloadable': True}, {'type': 'simple', 'virtual': True, 'regular_price': '121.99', 'name': 'бензобур 2020', 'downloadable': True}]}


but it should be
{"create": [{"type": "simple", "virtual": True, "regular_price": "21.99", "name": "дрель аккумуляторная 222", "downloadable": True}, {"type": "simple", "virtual": True, "regular_price": "121.99", "name": "бензобур 2020", "downloadable": True}]}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Pankov, 2020-10-28
@trapwalker

Flask doesn't change anything, it just deserializes json, and single quotes are string literals in python, not json.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question