我目前在我的scala.html文件中使用PropertyDTO的列表來使用Play2填充視圖。 propertyDTO具有包含JSON字符串的String屬性「value」。我想將此字符串轉換爲scala.html文件中的JSON對象,並遍歷JSON對象集合。當嘗試以下操作時,在scala.html文件中將字符串轉換爲JSON
val json = Json.parse(property.value),作爲scala代碼中的[JsObject],它打印表達式。我想知道我的方法是否正確,如果沒有,是否有適合的解決方案。
代碼 - > scala.html
@(propertyList : List[PropertyDTO])
@for(property <- propertyList){
@if(property.isInputProperty){
@if(property.propertyType=="BL"){
val json = Json.parse(property.value).as[JsObject]
}
}
}