Ich versuche, einen Lese-/Schreib-Wert für eine Fallklasse zu schreiben, für die viele der Werte möglicherweise null sind. Im Anschluss an die Tutorials Spielrahmen Ich schreibe es alsJSON-Lese-/Schreibfehler: Anwendung nimmt keine Parameter
implicit val incomingMessageWrites: Writes[IncomingMessage] = (
(JsPath \ "stageNum").write[Int] and
(JsPath \ "stage").write[String] and
(JsPath \ "stageTime").write[Long] and
(JsPath \ "vendorId").write[String] and
(JsPath \ "text").writeNullable[String] and
(JsPath \ "campaignCode").writeNullable[String] and
(JsPath \ "osTotals").writeNullable[OSTotals] and
(JsPath \ "splitSegment").writeNullable[Int] and
(JsPath \ "segmentNum").writeNullable[Int] and
(JsPath \ "osBatchStatus").writeNullable[OSBatchStatus]
)(unlift(IncomingMessage.unapply))
Allerdings halte ich das gleiche Problem zu begegnen, wo IntelliJ mir sagt, dass die Auftriebs Methode funktioniert nicht, weil „Application Hat Parameter Nicht Take“.
Die Fallklasse hierfür ist
case class IncomingMessage(
stageNum: Int,
stage: String,
stageTime: Long,
vendorId: String,
text: String,
campaignCode: String,
osTotals: OSTotals,
splitSegment: Int,
segmentNum: Int,
osBatchStatus: OSBatchStatus) {
def this(stageNum: Int, stage: String, stageTime: Long, vendorId: String, text: String, campaignCode: String) =
this(stageNum, stage, stageTime, vendorId, text, campaignCode, null, 0, 0, null)
def this(stageNum: Int, stage: String, stageTime: Long, splitSegment: Int, vendorId: String, text: String, campaignCode: String) =
this(stageNum, stage, stageTime, vendorId, text, campaignCode, null, splitSegment, 0, null)
def this(stageNum: Int, stage: String, stageTime: Long, segmentNum: Int, vendorId: String) =
this(stageNum, stage, stageTime, vendorId, null, null, null, 0, segmentNum, null)
def this(stageNum: Int, stage: String, stageTime: Long, segmentNum: Int, vendorId: String, osTotals: OSTotals) =
this(stageNum, stage, stageTime, vendorId, null, null, osTotals, 0, segmentNum, null)
def this(stageNum: Int, stage: String, stageTime: Long, vendorId: String, oSBatchStatus: OSBatchStatus) =
this(stageNum, stage, stageTime, vendorId, null, null, null, 0, 0, osBatchStatus)
}
Das gleiche für die andere Fall Klasse
case class OSBatchStatus(os: String, success: Int, failure: Int)
object OSBatchStatus {
implicit val oSBatchStatusReads: Reads[OSBatchStatus] = (
(JsPath \ "os").readNullable[String] and
(JsPath \ "success").readNullable[Int] and
(JsPath \ "failure").readNullable[Int]
)(OSBatchStatus.apply _)
}
geschieht wir lesen geschrieben haben und Werte schreiben, aber weggelassen sie Platz zu sparen.
Jede und alle Hilfe würde sehr geschätzt werden.
Diese aussortiert mein Problem. Vielen Dank – Xcoder