【发布时间】:2016-03-15 21:23:00
【问题描述】:
我从一个我无法控制的外部 API 获得这个 JSON,其中包含未定义数量的命名子对象,如下所示:
{
// ...
"promotions": {
"5": {
"id": 5,
"name": "Promo",
"translations": {
"fr": "Promo2",
"de": "Promo2",
// ...
}
},
"6": {
"id": 6,
"name": "Promo2",
"translations": {
"fr": "Promo2",
"de": "Promo2",
// ...
}
},
// ...
}
}
我希望使用 Play JSON 库(使用 Reads 组合器)将 promotions 的内容转换为 Promotion 对象列表,但我不知道如何处理。
【问题讨论】:
标签: json scala parsing playframework playframework-2.0