title: Json4S creating new object with updated value
body: <p>I am trying to update a specific field in a json object, the structure looks like this:</p>
  
  <pre><code>{ "foo": [
      { 
        "bar": {
          "ref": "ref to ignore", 
          "baz": { 
            "ref": "my_old_value"
   }}}]}
  </code></pre>
  
  <p>I am parsing this object with Json4S, using Jackson, and would like to create a new json object with the value of this specific "ref" field changed to a different value. I can display the current ref object:  </p>
  
  <pre><code>[scala&gt; json.\("foo")(0).\("bar").\("baz")
  res6: JObject(List((ref,JString(my_old_value))))
  </code></pre>
  
  <p>And I am able to use a transform/transformField function to generate a new object, I'll spare the details of the transform:</p>
  
  <pre><code>[scala&gt; val transformed = json.\("foo")(0).\("bar").\("baz").transform { ..
  transformed: JObject(List((ref,JString(my_new_value))))
  </code></pre>
  
  <p>I can not seem to figure out the correct way to create a new object in which he original 'ref' object has been replaced with the transformed 'ref' object in the overall json object. I also need to note that in my actual json object there are many 'ref' objects, i only need to update the specific one located at <code>json.\("foo")(0).\("bar").\("baz").("ref")</code></p>
  
  <p>I've tried both using the replace and flatMap functions to do this but cannot get it to work properly. Can anyone provide some advice on how to do this with Json4S? </p>
  
  <p>Thanks</p>