【发布时间】:2016-08-08 20:00:24
【问题描述】:
这是我一直遇到的一个奇怪问题。我有一个带有许多参数的案例类,包括一个字符串,并且能够使用 Play 的格式直接将其序列化为 JSON。然后,我添加了另一个参数 - 一个字符串 - 它开始抱怨
未找到 unapply 或 unapplySeq 函数
原来的样子是这样的:
case class PushMessage(stageOne: Boolean, stageTwo: Boolean, stageThree: Boolean, stageFour: Boolean, stageFive: Boolean,
highestStage: Int, iOSTotal: Int, androidTotal: Int, iOSRunningCount: Int, androidRunningCount: Int,
vendorId: String, androidProblem: Boolean, iOSComplete: Boolean, androidComplete: Boolean,
totalStageThrees: Int, totalStageFours: Int, totalStageFives: Int, expectedTotals: Int,
latestUpdate: Long, iOSProblem: Boolean, startTime: Long, date: Long)
新的看起来像
case class PushMessage(stageOne: Boolean, stageTwo: Boolean, stageThree: Boolean, stageFour: Boolean, stageFive: Boolean,
highestStage: Int, iOSTotal: Int, androidTotal: Int, iOSRunningCount: Int, androidRunningCount: Int,
vendorId: String, androidProblem: Boolean, iOSComplete: Boolean, androidComplete: Boolean,
totalStageThrees: Int, totalStageFours: Int, totalStageFives: Int, expectedTotals: Int,
latestUpdate: Long, iOSProblem: Boolean, startTime: Long, date: Long, topics: String)
唯一的区别是参数主题。
我的序列化器看起来像:
object PushMessage {
implicit val pushMessageFormat = Json.format[PushMessage]
}
我们将不胜感激。谢谢。
【问题讨论】:
标签: json scala serialization