python - 如何使得Flask的request.get_json()获取上来的JOSN与POST请求时的JSON顺序一致呢?
巴扎黑
巴扎黑 2017-04-17 17:12:33
0
2
820

这个需求的主要原因是第三方服务会POST一个JSON参与加密算法,用以给调用方确认第三方的正身。

现在的问题是,第三方服务POST过来的JSON顺序是1,2,3,通过request.get_json()上来的数据就是3,1,2,顺序不同导致效验结果就有差异。

有什么办法获取请求体的JSON同时不改变之前的JSON顺序?

巴扎黑
巴扎黑

reply all(2)
小葫芦

Did you have a problem with the order during the process of converting json to dictionary? When converting a dictionary, you can use the orderDict data structure

刘奇

You can write a custom json_decoder and then overwrite it

http://flask.pocoo.org/docs/0.10/api/#flask.Flask.json_decoder

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!