'Create Json file from Jobject using scala

I have a Jobject created in scala something like below:

JObject(List(JField(_id,JString("abc")), JField(metadata,JString({"foo":"qwe","ree":"rrr"}))))

Want to store this in file with JSON format like this

{
  "id" : "abc',
  "metadata" :
   {
     "foo" : "qwe",
     "ree" : "rrr"
   }
}

Also need to append this file with more similar Jobject structure using scala. I am using lift web library to handle JSON data.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source