Bob
Bob

Reputation: 592

How to create JSON object in Scala/Play

I need to create the following JSON object in Scala and Play framework, but I am having trouble:

{"employees":[
  {"firstName":"John", "lastName":"Doe"}
]}

The data used to create the object comes from a html form (already implemented). So far my code creates the following:

val json: JsValue = Json.toJson(formContent)
//returns = {"firstName":"John", "lastName":"Doe"} 

How can I add the the key "employees" to this object?

Can anyone help me?

Thanks

Upvotes: 2

Views: 3116

Answers (1)

aravindKrishna
aravindKrishna

Reputation: 440

Json.obj("employees"->Json.arr(JSON))

Upvotes: 6

Related Questions