Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to convert hashMap into json object in scala?

I want to convert hashmap into json object, my hashmap structure is look like this:

def res=Action{ implicit request=>
  var response=new HashMap[String,Map[String,String]]
  response=//etc .......
  .
  .
  .
  Ok(write(response))
}

bt its not working .

like image 906
Rohit Sharma Avatar asked Feb 13 '23 07:02

Rohit Sharma


1 Answers

Try this:

Ok(Json.toJson(response.toMap))

This would convert your HashMap to a Map which can be written as json without additional code.

like image 70
serejja Avatar answered Feb 16 '23 04:02

serejja