【发布时间】:2015-08-27 12:24:34
【问题描述】:
我正在使用 Scala Play 框架和 Instagram API,我想将一个 json 数组提取到我的模型类 User:
case class User(val userId: String, val username: String, val profilePhoto: String, val name: String)
API 中的 json 数组示例如下所示:
{
"pagination": {},
"meta": {},
"data": [
{
"username": "carolinabentocb",
"profile_picture": "https://igcdn-photos-f-a.akamaihd.net/hphotos-ak-xfa1/t51.2885-19/s150x150/11429783_1673078532912085_1496721162_a.jpg",
"id": "363753337",
"full_name": "Carolina Bento"
},
{
"username": "pereira3044",
"profile_picture": "https://igcdn-photos-e-a.akamaihd.net/hphotos-ak-xaf1/t51.2885-19/s150x150/11351764_1662987433917180_971708049_a.jpg",
"id": "2141448590",
"full_name": "Alex"
}
]
}
this link 中解释了如何将 json 对象映射到模型类,但是如何将 json 数组映射到用户的 Seq/List/Array?
【问题讨论】:
标签: json scala playframework playframework-2.0