Validation error while trying to parse a json array to List[Object] in Scala

Viewed 3927

I have a method that returns a JsArray of a type Foo.

To process the response, I am doing the following:

val foos : List[Foo] = Json.toJson(result).as[List[Foo]]

While debugging, I could see that the result is comming as:

"[]"

and it is generated by the code:

Ok(Json.toJson(foos))

Where foos is a List[Foo]

But I am getting the error:

[JsResultException: JsResultException(errors:List((,List(ValidationError(error.expected.jsarray,WrappedArray())))))]

I've tried many ways, but can't solve this.

What I am doing wrong?

2 Answers
Related