Pages

Wednesday, June 14, 2017

How to set null value in dictionary in python

How to set null value in dictionary in python

My requirement was like a REST Services running on server in Java and a python client, to get data as JSON. Data to the POST Call require a  null value to passed to a key (arguments). See this example, how to set null value in dictionary in python.

arguments='''{"jsonrpc": "2.0", "method": "enumerateMS", "params": null, "id" : 1}'''

Please see the complete code here.


import requests
url="http://IPAddress:PORT/Action"
arguments='''{"jsonrpc": "2.0", "method": "enumerateMS", "params": null, "id" : 1}'''
r=requests.post(url,data=arguments) 


Reference:
https://stackoverflow.com/questions/27140090/how-can-json-data-with-null-value-be-converted-to-a-dictionary?answertab=votes#tab-top

No comments:

Post a Comment