如何在Scala / Play中创建JSON对象(How to create JSON object in Scala/Play)
我需要在Scala和Play框架中创建以下JSON对象,但是我遇到了麻烦:
{"employees":[ {"firstName":"John", "lastName":"Doe"} ]}用于创建对象的数据来自html表单(已实现)。 到目前为止我的代码创建了以下内容
val json: JsValue = Json.toJson(formContent) //returns = {"firstName":"John", "lastName":"Doe"}如何将“雇员”键添加到此对象?
谁能帮我?
谢谢
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
最满意答案
Json.obj("employees"->Json.arr(JSON)) Json.obj("employees"->Json.arr(JSON))更多推荐
发布评论