Input : {"id": null, "type": null, "order_for": null, "name": "Name"}
コード:
input_map = simplejson.dumps(eval(line))
print type(input_map)
戻り値
<type 'str'>
ここの何が問題になっていますか?
ありがとうございました
Input : {"id": null, "type": null, "order_for": null, "name": "Name"}
コード:
input_map = simplejson.dumps(eval(line))
print type(input_map)
戻り値
<type 'str'>
ここの何が問題になっていますか?
ありがとうございました
おそらくあなたは意味しました:
print(input_map)
nullまた、で使用する場合はline、evalを上げる必要がありNameErrorます。代わりに使用できますsimplejson.loads:
import simplejson
line='{"id": null, "type": null, "order_for": null, "name": "Name"}'
input_map = simplejson.loads(line)
print(input_map)
# {u'order_for': None, u'type': None, u'id': None, u'name': u'Name'}
print(simplejson.dumps(input_map))
# {"order_for": null, "type": null, "id": null, "name": "Name"}