json.dumps output error in python3 - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: json.dumps output error in python3 (/thread-23861.html) |
json.dumps output error in python3 - prayuktibid - Jan-21-2020 I am trying to send a dict file in JSON fromat usin "ujson.dumps" method to local http server. After executing ujson.dumps the output get changes. This is my code import ujson file ={ "success": true, "status_code": 200, "version": "1.2.0003", "path": "/get_capture_options", "method": "GET", "capture_options": [ { "width": 1920, "framerate": 30, "height": 1080 }, { "width": 1280, "framerate": 30, "height": 720 }, { "width": 1280, "framerate": 60, "height": 720 }, { "width": 640, "framerate": 30, "height": 480 }, { "width": 640, "framerate": 60, "height": 480 }, { "width": 640, "framerate": 90, "height": 480 } ] } file2 = ujson.dumps(file).encode('utf-8') print(file2)This is the output: Quote: b'{"success":true,You can seen in path parameter the "\\" added. Why is this happening? how to solve this? Please help. RE: json.dumps output error in python3 - buran - Jan-21-2020 Looking at the docs, there is option escape_forward_slashes , which controls whether forward slashes (/) are escaped. Default is True.If you are going to use third-party package, at least make an effort to read the [relevant part of] the docs RE: json.dumps output error in python3 - prayuktibid - Jan-21-2020 Thank you |