I've a case class similar to this found here :
case class WebCategory(topGroupName: String,
topGroupID: String,
webCategoryName : String,
webCategoryID : String,
subWebCats:Seq[SubWebCat])
case class SubWebCat(name:String, id:String)
And my request body json is having the exact same key names as of case class. For ex:
{
"webCategoryID" : "blah",
"webCategoryName" : "abcabc",
"topGroupID" : "blah",
"topGroupName" : "namehere",
"subWebCats" : [
{
"name" : "blah",
"id" : "idblah"
},
{
"name" : "another blah",
"id" : "another idblah"
}
]
}
The case class & req body keys are same then is it possible to directly build the case class object from request json? If it is possible then how can I do this? Any references would help. If it is not possible then this means I've to define my custom implicit converter explained in the answer in which I don't have any problem implementing it.
Note: I'm using Play 2.3 & Scala 11 for my development