google / google/python-fire

How can I get json param

未關閉
#297 1 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
question
主要語言
Python
星號
28.2k
分支
1.5k
PR 合併指標
30 天內沒有已合併 PR

描述

`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]}
```

貢獻指南

開啟貢獻指南

研究方向

Start with the test.py example and run both command lines shown in the issue to reproduce the differing argument parsing. Read the Python Fire argument-parsing path involved, then determine whether dotted JSON values should remain a dictionary; done requires either a confirmed fix with a regression test or a clear documented limitation.

由索引模型根據 Issue 內容生成。

評估

技術堆疊
json, python
領域
cli
Issue 類型
缺陷
難度
3/5
預估耗時
1-2 天
活躍度
停滯
描述清晰度
需要釐清
新手友好度
25/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。