You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@pyus-13 set function only could change the value whith the path exists. If you want to add a new path, you could use put function to achive it.
In your case, you could write like this:
Stringjson = "{\"properties\": {}}";
DocumentContextcontext = JsonPath.parse(json);
context.put("$.properties", "image", newHashMap<>()); // add a new path "$.properties.image"context.put("$.properties.image", "source","image_url"); // continue to add a new path "$.properties.image.source"StringnewJson = context.jsonString();
StringexpectedNewJson = "{\"properties\":{\"image\":{\"source\":\"image_url\"}}}";
Assert.assertEquals(expectedNewJson, newJson);
Eg the Json is
val json = JsonPath.parse(myJson).set("$.properties.image.source", "my_image_url").jsonString()
Log.d("", "JSON UPDATED $json")
returns
instead of
The test method in Kotlin.
The text was updated successfully, but these errors were encountered: