我在读取 Groovy 中 HTTPBuilder 提供的 JSON 响应时遇到异常。请在下面找到 JSON 字符串。我收到不带引号的 JSON 响应。我正在使用 Groovy HTTPBuilder。
String x = {
apenvironments = [], temptype = dflt, audit = {
createdAt = 1438605399389,
createdBy = xxxxxx testing
}, basicInfo = {
id = AU7zkFVftRWGykHHiM1R,
name = MED_FREQ83282
}, id = AU7zkFVftRWGykHHiM1R, name = MED_FREQ83282,
policyElements = [{
authenticationType = AUTH12, type = AUTH
}, {
aggType = COUNT, soft = false, targets = [{
targetType = APPS, type = BasePolicyElementTarget
}], type = numrclmt, value = 5, valueEqualsZero = false
}, {
aggType = COUNT, soft = false, targets = [{
targetType = DEVICE, type = BasePolicyElementTarget
}], type = numerratlimt, value = 3, valueEqualsZero = false
}, {
enabled = true, type = ANALYTICS
}, {
meteringPayloadType = REQUEST, metricField = PAYLOAD, type = PAYLOAD_METERING
}, {
field = PAYLOAD, load = {
bandwidthUnit = KB, payloadType = REQUEST, type = payload, value = 26
}, soft = false, type = Payload, valueEqualsZero = false
}, {
aggType = COUNT, soft = false, targets = [{
targetType = USER, type = elementTarget
}], type = ratelt, value = 4, valueEqualsZero = false
}, {
hitType = ALL, metricField = HITS, type = meter
}, {
frequencyUnit = MINUTE, hits = {
hitType = ALL, hits = 3
}, metricField = HITS, soft = false, type = freqratelt, valueEqualsZero = false
}], templateName = tempv, type = plctem
};
ObjectMapper mapper = new ObjectMapper();
try {
JsonNode df=mapper.readValue(x,JsonNode.class);
…………………………………………………………………………
异常: com.fasterxml.jackson.core.JsonParseException:意外字符('a'(代码 97)):期待双引号开始字段名称
请帮助我。