是否可以使用任何内置Scala API将对象编组为JSON



是否可以使用任何内置Scala API将对象编组为JSON?由于某种原因,我不能使用任何库,如杰克逊,播放等

我知道Scala提供JSON解析器(Scala.util.panalysing.JSON.JSON),但我对marshaller感兴趣。

case class和Play的JSON readswrites宏可以为您完成此操作。Play的Doc

不确定您在寻找什么。但是,如果您需要JSON来响应某些REST API,并且您正在使用import org.springframework.web.bind.annotation.{RequestMapping,RequestMethod,RestController}

然后你可以返回这样的地图地图("startDate"->startDate.toDate,"endDate"->endDate.toDate,"locations"->myLocations.map{locationId=>地图("location"->locationId.name,"locationZone"->locationId.timeZone)})

否则,与案例类

一起播放会很容易

最新更新