【发布时间】:2018-12-28 18:40:40
【问题描述】:
我正在尝试使用 Play Json 和隐式解析 Scala 中的一些有问题的 Json,但不确定如何继续...
Json 看起来像这样:
"rules": {
"Some_random_text": {
"item_1": "Some_random_text",
"item_2": "text",
"item_n": "MoreText",
"disabled": false,
"Other_Item": "thing",
"score": 1
},
"Some_other_text": {
"item_1": "Some_random_text",
"item_2": "text",
"item_n": "MoreText",
"disabled": false,
"Other_Item": "thing",
"score": 1
},
"Some_more_text": {
"item_1": "Some_random_text",
"item_2": "text",
"item_n": "MoreText",
"disabled": false,
"Other_Item": "thing",
"score": 1
}
}
我使用的是隐式阅读器,但因为 rules 中的每个顶级项目实际上都是不同的东西,我不知道如何解决这个问题......
我正在尝试构建一个案例类,我实际上并不需要每个项目的随机文本标题,但我确实需要每个项目。
为了让我的生活更加艰难,因为这些项目中有很多我真的不需要的其他格式的东西。它们是刚开始的未命名项目: { 随机合法的Json ... }, { 更多 Json... }
我需要在一系列案例类中解析我正在解析的 Json。
感谢您的意见。
【问题讨论】: