Enrico
Enrico

Reputation: 3454

In notepad ++ how can I remove a property from all items in a json list

I have a large json list that has this structure

  {
    "name": "my name",
    "description": "my description",
    "image": "image.png",       
    "id": 1
  },
  {
    "name": "my name",
    "description": "my description",
    "image": "image.png",       
    "id": 2
  }
...

My list is 100 items long. Is there a way to remove the "id" property (and value) from all the objects in the list using notepad++?

Upvotes: 0

Views: 3516

Answers (2)

yamaro
yamaro

Reputation: 23

I would say just use the find & replace function: For example:

You want to remove the property image, just use:

Find = "image": ".*",

Replace = 

Search Mode = Regular expression

Upvotes: 1

Toto
Toto

Reputation: 91385

  • Ctrl+H
  • Find what: ,\s+"id":.+
  • Replace with: LEAVE EMPTY
  • CHECK Match case
  • CHECK Wrap around
  • CHECK Regular expression
  • UNCHECK . matches newline
  • Replace all

Explanation:

,           # a comma
\s+         # 1 or more spaces, including linebreak
"id":       # literally
.+          # 1 or more any character but newline

Screenshot (before):

enter image description here

Screenshot (after):

enter image description here

Upvotes: 4

Related Questions