deleting a key inside of an object inside an array doesn't work as expected
Opened this issue · 1 comments
sebastiandeutsch commented
I'm using the json from the readme:
json = <<-HERE_DOC
{"store":
{"bicycle":
{"price":19.95, "color":"red"},
"book":[
{"price":8.95, "category":"reference", "title":"Sayings of the Century", "author":"Nigel Rees"},
{"price":12.99, "category":"fiction", "title":"Sword of Honour", "author":"Evelyn Waugh"},
{"price":8.99, "category":"fiction", "isbn":"0-553-21311-3", "title":"Moby Dick", "author":"Herman Melville","color":"blue"},
{"price":22.99, "category":"fiction", "isbn":"0-395-19395-8", "title":"The Lord of the Rings", "author":"Tolkien"}
]
}
}
HERE_DOC
and trying to remove an attribute of an arrayobject
JsonPath.for(json).delete("$.store.book[0].category")
Unfortunately it removes the complete book object:
{"store"=>
{"bicycle"=>{"price"=>19.95, "color"=>"red"},
"book"=>
[{"price"=>12.99, "category"=>"fiction", "title"=>"Sword of Honour", "author"=>"Evelyn Waugh"},
{"price"=>8.99, "category"=>"fiction", "isbn"=>"0-553-21311-3", "title"=>"Moby Dick", "author"=>"Herman Melville", "color"=>"blue"},
{"price"=>22.99, "category"=>"fiction", "isbn"=>"0-395-19395-8", "title"=>"The Lord of the Rings", "author"=>"Tolkien"}]}}
expected:
{"store":
{"bicycle":
{"price":19.95, "color":"red"},
"book":[
{"price":8.95, "title":"Sayings of the Century", "author":"Nigel Rees"},
{"price":12.99, "category":"fiction", "title":"Sword of Honour", "author":"Evelyn Waugh"},
{"price":8.99, "category":"fiction", "isbn":"0-553-21311-3", "title":"Moby Dick", "author":"Herman Melville","color":"blue"},
{"price":22.99, "category":"fiction", "isbn":"0-395-19395-8", "title":"The Lord of the Rings", "author":"Tolkien"}
]
}
}
@Skarlso any ideas?
Skarlso commented
Hello.
No idea, sorry. I haven't been a maintainer of this project for over 4 years. :D