在阅读JSON响应时获得异常

时间:2015-08-03 14:06:30

标签: json groove

我在阅读由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)):期待双引号开始字段名称

请帮我解决这个问题。

0 个答案:

没有答案