【发布时间】:2015-09-01 16:34:37
【问题描述】:
给定一个示例 JSON 对象,其中包含一个属性未知的嵌套对象:
{ "Key":"01234",
"eventProperties":{
"unknownProperty1":"value",
"unknownProperty2":"value",
"unknownProperty3":"value"
},
}
我曾尝试将 json4s 的提取函数与以下案例类(在 Scala 中)一起使用:
case class nestedClass(Key:String, eventProperties:Map[(String,Any)])
这会导致以下错误:
org.json4s.package$MappingException: Can't find constructor for nestedClass
是否可以在不定义 eventProperties 的所有可能属性的情况下做到这一点?
更新: json4s 3.2.10 中有一个错误导致此问题 - 更新到 3.2.11 并提取到 Map[String,Any] 工作正常。
【问题讨论】: