Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can you delete from objects in an array? #17

Open
nixta opened this issue Nov 21, 2018 · 1 comment
Open

Can you delete from objects in an array? #17

nixta opened this issue Nov 21, 2018 · 1 comment

Comments

@nixta
Copy link

nixta commented Nov 21, 2018

Let's say I have JSON that includes an array, each element of which is a JSON object. Can I modify those objects?

{
  "items" : [
    { "geometry" : [0,0], "properties": { "name": "Null Island", "area": 1000 } },
    { "geometry" : [40.7128,-74.0060], "properties": { "name": "Manhattan", "area": 14604 } }
  ]
}

I can select and view items.#.properties.area, but I'd like to delete area from each item. Is that possible but I'm just doing it wrong?

@c-nv-s
Copy link

c-nv-s commented Oct 10, 2023

I'm also interested in if there is a way to delete an entire object from the array if you don't know the index... i.e. by specifying a condition
it would be nice to say jj -D items.#[item_name="x"] or jj -D items.#[properties.name="Manhattan"]
at the moment this seems to result in error: cannot delete value from a complex path :-( so I'm having to resort back to jq
I'll probably raise new ticket if nobody can suggest a work around for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants