json-lenses
json-lenses copied to clipboard
Unable to set missing value using jsonPath expression
I'm trying to construct a JSON object using multple JsonPath expressions and values extracted from different sources. The following snippet reproduces the problem I'm facing. Namely, the set operation doesn't work on JsonPath expressions. json.update('object_id ! set(1))
works as expected.
val json = JsObject()
val lens = JsonLenses.fromPath("$.object_id")
val updated = json.update(lens ! set(1))
In this case updated
will be an empty object.
Hi! I'm having the same problem. Is this intended behavior? If so, an alternative way to update an object creating all required intermediate keys in the process would be very useful :)