python-fire icon indicating copy to clipboard operation
python-fire copied to clipboard

How can I get json param

Open hbh112233abc opened this issue 5 years ago • 1 comments

test.py

import fire

def hello(name):
    print(name)
    print(name.get('a'))

if __name__ == "__main__":
    fire.Fire(hello)

example:

python test.py '{"a":"aaa","b":[1,2,3]}'

the param name is json dict, result print:

{'a':'aaa','b':[1,2,3]}
'aaa'

but when input:

python test.py '{"a":"aa.a","b":[1,2,3]}'

the param name can't parse to json, it's a str,how can I get the json param??

{a:aa.a,b:[1,2,3]}

hbh112233abc avatar Nov 16 '20 09:11 hbh112233abc

environment: win10 64bit python3.6 32bit fire 0.3.1

linux centos8 not found this problem!

hbh112233abc avatar Nov 17 '20 01:11 hbh112233abc