json-lenses icon indicating copy to clipboard operation
json-lenses copied to clipboard

Unable to set missing value using jsonPath expression

Open thecodingrobot opened this issue 9 years ago • 1 comments

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.

thecodingrobot avatar Nov 03 '15 20:11 thecodingrobot

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 :)

ruippeixotog avatar Jul 05 '17 16:07 ruippeixotog