score:23

Accepted answer

Your code is correct except that your JSON is simply an array, hence a List[User]. There are two ways to fix this, with a slightly different outcome:

Solution 1: Fix your json to

{"users": 
  [
    {"name": "Foo", "emails": ["Foo@gmail.com", "foo2@gmail.com"]},
    {"name": "Bar", "emails": ["Bar@gmail.com", "bar@gmail.com"]}
  ]
}

Solution2: Change the type parameter of extract to

val obj = parse(json).extract[List[User]]

Related Query

More Query from same tag