मैं प्ले फ्रेमवर्क 2.3x में कुछ स्कैला मॉडल कक्षाओं के लिए जेएसओएन सत्यापन लिखना चाहता हूं। मैं निर्देशों का पालन करने के लिए जेएसओएन रीड का उपयोग कर रहा हूं (https://playframework.com/documentation/2.3.x/ScalaJsonCombinators)। लेकिन मुझे लगता है कि "एप्लिकेशन पैरामीटर नहीं लेता है" त्रुटि और मुझे नहीं पता कि इसे कैसे ठीक किया जाए।प्ले फ्रेमवर्क 2.3 के साथ जेएसओएन रीड का उपयोग करके मुझे "पैरामीटर नहीं लेते हैं" क्यों मिलता है?
मेरा कोड यहां है।
package models
import play.api.libs.json._
import play.api.libs.json.Reads._
import play.api.libs.functional.syntax._
import reactivemongo.bson.BSONObjectID
import java.util.Date
case class ArtifactModel(
_id: BSONObjectID,
name: String,
createdAt: Date,
updatedAt: Date,
attributes: List[AttributeModel],
stateModels: List[StateModel])
case class AttributeModel(
name: String,
comment: String)
case class StateModel(
name: String,
comment: String)
object ArtifactModel {
implicit val artifactModelReads: Reads[ArtifactModel] = (
(__ \ "_id").readNullable[String] ~
(__ \ "name").read[String] ~
(__ \ "createdAt").readNullable[Long] ~
(__ \ "updatedAt").readNullable[Long] ~
(__ \ "attributes").read[List[AttributeModel]] ~
(__ \ "stateModels").read[List[StateModel]]
)(ArtifactModel) // here is the error: "Application does not take parameters"
implicit val attributeModelReads: Reads[AttributeModel] = (
(__ \ "name").read[String] ~
(__ \ "comment").read[String]
)(AttributeModel)
implicit val stateModelReads: Reads[StateModel] = (
(__ \ "name").read[String] ~
(__ \ "comment").read[String]
)(StateModel)
}
क्या आप मेरी मदद कर सकते हैं? स्कैला/प्ले में जेएसओएन सत्यापन के लिए कोई समाधान या सुझाव सराहना की जाती है।
मैं पहले से ही है कि कोशिश लेकिन इसके लिए काम नहीं करता है मुझे। त्रुटि वही है। मैं उलझन में हूं। – Raysmond
को संकलित करने और उत्तर को अपडेट करने के लिए चीज़ मिल गई। –
बहुत बहुत धन्यवाद। यह इस तरह से काम करता है। – Raysmond