我有一个具有以下结构的json:
{
"name":"mark",
"address": "\r\n[\r\n{\r\n\"line1\":\"careve\",\r\n\"line2\":\"roxn\",\r\n\"line3\":\"asdef\"\r\n},\r\n{\r\n\"line1\":\"wedf\",\r\n\"line2\":\"aswd\",\r\n\"line3\":\"xsqa\"\r\n}\r\n]\r\n"
}
转义后,我得到了:
{
"name": "mark",
"address": " [ { "line1":"careve", "line2":"roxn", "line3":"asdef" }, { "line1":"wedf", "line2":"aswd", "line3":"xsqa" } ] "
}
案例类别:
case class Details(name:String,address:List[Address])
case class Address(line1:String,line2:String,line3:String)
我知道address
期望一个List[Address]
,但是它以字符串形式出现,因此也不会因为我得到明显的错误而强制转换
Exception in thread "main" net.liftweb.json.MappingException: No usable value for address
Expected collection but got JString(
[
{
"line1":"careve",
"line2":"roxn",
"line3":"asdef"
},
{
"line1":"wedf",
"line2":"aswd",
"line3":"xsqa"
}
]
) for root JString(
如何将其解析为案例类?