title: Get data from database in form of JSON in PLAY(Scala)
body: <p>I am new to Play 2.1 and Scala. I am from node.js background &amp; it returns result from database directly in JSON form. What I want is to get the data from database in JSON form in Play(Scala). I have tried Json.toJson but it shows error of deserializer or something. Can anybody find me a solution to this problem with a model &amp; controller description. Thanks in advance. </p>
  
  <p>I am using Mysql database.
  Here is model code...</p>
  
  <pre><code>import anorm.SqlParser._
  import play.api.db.DB
  
  //class definition
  case class     Data(Date_Time_id:BigInteger,Details:String,Image:Strig,Status:Boolean,Type:String)
  
  object Model{
      def getDetails(Person_id:Long):Map[BigInteger,Data]={
  
      DB.withConnection{ implicit c=&gt; 
  
  val result=SQL("""select Date_Time_id,Details,Image,
      ,Status,Type from table1 where  Person_id={perId} 
      """).on("perId"-&gt;Person_id)
  
  //mapping result
  val detailss=result().map(row=&gt;
          row[BigInteger]("Date_Time_id")-&gt;row[BigInteger]("Date_Time_id"),row[String]("Details"),row[String]("Image"),row[Boolean]("Status"),row[String]("Type"))).toMap
      return detailss
  
  }
  }
  </code></pre>
  
  <p>I am calling it from controller like:</p>
  
  <pre><code>var getResult=Model.getDetails(some Id)
  </code></pre>