Yamlbeans解析异常com.beans.Score字段的预期数据但找到:标量

时间:2011-10-05 09:58:58

标签: yaml

需要Yamlbeans(v1.06)的一些帮助,我试图解析以下消息:

{MessageId:123,ReceiptHandle:receiptHandle,MD5OfBody:34536563,Body:!com.beans.Score
created_at:'“2010-03-29”'
custom_1:20
custom_3:S1040PERbfdi10103216
exit_code:1
first_activity_at:'“2010-03-29”'
last_activity_at:'“2010-03-29”'
prod_id:0
得分:'“0.549305”'
,属性:{},}

以下是我用来解析的代码片段:     YamlReader reader = new YamlReader(msg);     Object object = reader.read();

错误: com.esotericsoftware.yamlbeans.YamlReader $ YamlReaderException:第17行,第1列:com.beans.Score字段的预期数据但找到:标量     在com.esotericsoftware.yamlbeans.YamlReader.readValueInternal(YamlReader.java:357)     在com.esotericsoftware.yamlbeans.YamlReader.readValue(YamlReader.java:156)     at com.esotericsoftware.yamlbeans.YamlReader.readValueInternal(YamlReader.java:289)     在com.esotericsoftware.yamlbeans.YamlReader.readValue(YamlReader.java:156)     在com.esotericsoftware.yamlbeans.YamlReader.read(YamlReader.java:106)     在com.esotericsoftware.yamlbeans.YamlReader.read(YamlReader.java:91)     在com.esotericsoftware.yamlbeans.YamlReader.read(YamlReader.java:83)

有人可以帮忙吗?

1 个答案:

答案 0 :(得分:0)

1)确保您的分数字段(created_at,custom_1等)从分数声明中缩进,例如:

Body: 
    !com.beans.Score
        created_at: '"2010-03-29 "'
        custom_1: 20

2)您通常不需要像2010-03-29

这样的标量值的引号