我正在尝试运行一个带有单引号的JSON输入的Ansible剧本。运行剧本失败,出现以下错误。有没有办法解析一下单引号。到目前为止,我的错误越来越少。
JSON: Expecting value: line 1 column 1 (char 0)
Syntax Error while loading YAML.
expected <block end>, but found '<scalar>'
ERROR! We were unable to read either as JSON nor YAML, these are the errors we got from each:
JSON: Expecting value: line 1 column 1 (char 0)
Syntax Error while loading YAML.
expected <block end>, but found '<scalar>'
The error appears to be in line 161, column 69, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
"logGroups": "aws_log_group_name",
"query": "fields @timestamp, @message | parse @message 'GET *:4' as apiName | parse @message ':443* H' as backend | sort @timestamp desc | stats count() as count by backend | sort count desc"
^ here
杰森:
{
"type": "custom",
"width": 24,
"height": 18,
"properties": {
"params": {
"region": "us-east-1",
"logGroups": "aws_log_group",
"query": "fields @timestamp, @message | parse @message 'GET *:4' as apiName | parse @message ':443* H' as backend | sort @timestamp desc | stats count() as count by backend | sort count desc"
},
"updateOn": {
"refresh": true,
"timeRange": true
},
"title": "ELB logs"
}
}
发布于 2022-11-18 08:18:32
是有效的JSON
shell> cat dashboard.json
{
"type": "custom",
"width": 24,
"height": 18,
"properties": {
"params": {
"region": "us-east-1",
"logGroups": "aws_log_group",
"query": "fields @timestamp, @message | parse @message 'GET *:4' as apiName | parse @message ':443* H' as backend | sort @timestamp desc | stats count() as count by backend | sort count desc"
},
"updateOn": {
"refresh": true,
"timeRange": true
},
"title": "ELB logs"
}
}
下面的剧本按预期工作。
- hosts: localhost
tasks:
- include_vars:
file: dashboard.json
name: dashboard
- debug:
var: dashboard
https://stackoverflow.com/questions/74486629
复制相似问题