Created
February 6, 2018 14:48
-
-
Save nkentaro/6d28dcc04c88e33492c54117edbf0399 to your computer and use it in GitHub Desktop.
Nested dict to nested JSON
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from your_own_facility import YourOwnWSService | |
ws = YourOwnWSService('wss://example.com/WSAPI/') | |
message = { | |
"m": 0, | |
"i": 55, | |
"n": "YourName", | |
"o": "" | |
} | |
payload = { | |
"OMSId": 1, | |
"ProductId": i+1 | |
} | |
message['o'] = json.dumps(payload) # you need to encode dict if you have a child dict | |
ws.send(json.dumps(message)) # and you would need to encode the outer dict again to make a correct JSON |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment