title: How to add new node to Json using JsonPath?
body: <p>I'm working with JSON and facing some problems.</p>
  
  <p>I want to insert/update a path in a JSON object. In the case that the path doesn't exist, it will be created then I insert a new value. In case that it exits, it will be updated by a new value</p>
  
  <p>For example, I want to add new path like this:</p>
  
  <pre><code>val doc = JsonPath.parse(jsonString)
  doc.add("$.user.name", "John")
  </code></pre>
  
  <p>but I always get this error, because the path doesn't exist:</p>
  
  <blockquote>
    <p>class com.jayway.jsonpath.PathNotFoundException : Missing property in path $['user']</p>
  </blockquote>
  
  <p>Therefore I want to create a new path if it does not exist.</p>
  
  <p>This is my code, but <code>jsonString</code> doesn't change:</p>
  
  <pre><code>var jsonString = "{}" val conf = Configuration.defaultConfiguration().addOptions(Option.DEFAULT_PATH_LEAF_TO_NULL).addOptions(Option.SUPPRESS_EXCEPTIONS)
  JsonPath.using(conf).parse(jsonString).set(JsonPath.compile("$.user.name"), "John") 
  Log.d("TAG", "new json = $jsonString") 
  </code></pre>
  
  <p>Please give me your advice. Thank you very much!!</p>