这是我一直有的一个奇怪的问题。我有一个包含许多参数的case类,包括一个字符串,并且能够使用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]
}
任何和所有帮助将不胜感激。感谢。
答案 0 :(得分:3)
Play使用宏和元组来派生Json实例。问题是元组在Scala中仅限于22个字段(至少在目前)。
这意味着Play无法自动派生Json实例,尽管您可以通过手动编写它来解决它。
您可以在此处找到更多信息:Play Framework Scala format large JSON (No unapply or unapplySeq function found)