Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7895179
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T07:34:48+00:00 2026-06-03T07:34:48+00:00

This is my Search Object: package models.helper import play.api.libs.json.Format import play.api.libs.json.JsValue import play.api.libs.json.JsObject import

  • 0

This is my Search Object:

package models.helper
import play.api.libs.json.Format
import play.api.libs.json.JsValue
import play.api.libs.json.JsObject
import play.api.libs.json.JsString

case class Search (name: String, `type`:String){

  implicit object SearchFormat extends Format[Search] {
    def reads(json: JsValue): Search = Search(
      (json \ "name").as[String],
      (json \ "type").as[String]
    )

    def writes(s: Search): JsValue = JsObject(Seq(
        "name" -> JsString(s.name),
        "type" -> JsString(s.`type`)
    ))  
  }
}

I’m trying ot use this class when calling a webservice using WS:

val search = response.json.as[Search]

But the scala compiler keeps complaining on this line:

No Json deserializer found for type models.helper.Search. Try to
implement an implicit Reads or Format for this type.

Could anybody tell me what I’m doing wrong?

  • got the example from https://sites.google.com/site/play20zh/scala-developers/working-with-json
  • this thread discusses the same issue but gives no solution, what example on what site? https://groups.google.com/forum/?fromgroups#!topic/play-framework/WTZrmQi5XxY
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T07:34:50+00:00Added an answer on June 3, 2026 at 7:34 am

    Indeed the example is wrong. You need your implicit Format[Search] value to be available in the implicit scope.

    In your case the Format[Search] is defined as a nested value of the class Search, so you can reach it only from an instance of Search.

    So, what you want to do is to define it in another place, where it could be referenced without having to create an instance of Search, e.g. in a Formats object:

    object Formats {
      implicit SearchFormat extends Format[Search] {
        …
      }
    }
    

    Then you can use it as follows:

    import Formats.SearchFormat
    val search = response.json.as[Search]
    

    You can also get rid of the import tax by defining the Format[Search] value in the companion object of the Search class. Indeed the Scala compiler automatically looks in companion objects of type parameters when it needs an implicit value of a given type:

    case class Search(name: String, `type`: String)
    
    object Search {
      implicit object SearchFormat extends Format[Search] {
        …
      }
    }
    

    Then you can use it without having to import it:

    val search = response.json.as[Search]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How to I format a query string so it looks like this search?q=power+tools currently
So i need this format json and i have this so far { query:'Li',
I've implemented this search algorithm for an ordered array of integers. It works fine
I would like to know how to run a file like this: Search-Mailbox -Identity
I have a custom search engine on a non-wordpress page. This search engine searches
I'm getting a nothing to repeat error when I try to compile this: search
I got this url /search/renttype-all.place-all.type-all.bedrooms-all.0.0/ I want to get the text after the second
I want something like this: abcdab.search(/a/g) //return [0,4] Is it possible?
In the below javascript, this refers to Car object and search_id refers to the
How could I access the symbol table for the current package an object was

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.