ValueError:使用WGET过滤来自Linux中CLI的简单api请求时,无法解码JSON对象

问题描述 投票:0回答:1

基本上,我不能在简单的linux机器上使用curl,但是我有WGET。我有这个json

{
 "inStandby": "false", 
 "currservice_begin": "10:38", 
 "currservice_begin_timestamp": 34332, 
 "currservice_end_timestamp": 15759723423500, 
 "muted": false, 
 "isRecording": "false", 
 "currservice_station": "02 2 HD", 
 "currservice_serviceref": "1:0:19:4B0:1:1:334:0:0:0:", 
 "currservice_description": "Mv i v", 
 "volume": 50, 
 "currservice_fulldescription": "asdfasd", 
 "currservice_filename": "", 
 "transcoding": true, 
 "currservice_end": "11:25", 
 "currservice_id": 36172
}

我正在尝试仅将“ currservice_serviceref”值打印到文件中。我尝试过

wget localhost/api/statusinfo | python -c 'import json,sys;data=json.load(sys.stdin);print data["currservice_serviceref"]'
python api command-line-interface wget
1个回答
0
投票

我通过添加-qO-(打印到stdout来解决),因为我认为python试图从stdin(sys.stdin)读取。

© www.soinside.com 2019 - 2024. All rights reserved.