How to replace a JSON value in Play

后端 未结 5 1906
遥遥无期
遥遥无期 2020-12-31 01:58

How do I replace a value in a JSON value in Play?
Code to illustrate:

def newReport() = Action(parse.json) { request =>
    var json = request.bod         


        
5条回答
  •  暖寄归人
    2020-12-31 02:49

    I'm considering moving away from all of those immutable "JSON" solutions. It's just making the code a horrible mess. This is how it would look in SON of JSON:

    import nl.typeset.sonofjson._
    
    val json = …
    if (json.customerId.as[Int] == -1) {
      json.customerId = 987938
    }
    

提交回复
热议问题