Tenho o seguinte JSON e estou tentando substituí- null
lo nil
porque o Ruby não consegue compilá-lo.
Recebo o seguinte erro undefined local variable or method "null" for main:Object (NameError)
.
Descrição do alarme e unidade é null
.
Como posso resolver isso?
jsondata = {
AlarmName: "Zabbix PY 5XX - By Stage QA",
AlarmDescription: null,
AWSAccountId: "123456",
NewStateValue: "ALARM",
NewStateReason:
"Threshold Crossed: 1 out of the last 1 datapoints [1.0 (06/11/21 12:16:00)] was greater than or equal to the threshold (1.0) (minimum 1 datapoint for OK -> ALARM transition).",
StateChangeTime: "2021-11-06T12:17:43.811+0000",
Region: "Asia Pacific (Mumbai)",
AlarmArn: "arn:aws:cloudwatch:ap-south-1:123456:alarm:Zabbix PY 5XX - By Stage QA",
OldStateValue: "INSUFFICIENT_DATA",
Trigger: {
MetricName: "5XXError",
Namespace: "AWS/ApiGateway",
StatisticType: "Statistic",
Statistic: "MINIMUM",
Unit: null,
Dimensions: [
{ value: "zabbixPy-API", name: "ApiName" },
{ value: "qa", name: "Stage" },
],
Period: 60,
EvaluationPeriods: 1,
ComparisonOperator: "GreaterThanOrEqualToThreshold",
Threshold: 1,
TreatMissingData: "- TreatMissingData: missing",
EvaluateLowSampleCountPercentile: "",
},
}
puts jsondata
Erro:
Output:
HelloWorld.rb:6:in `<main>': undefined local variable or method `null' for main:Object (NameError)
AlarmDescription: null,