Search code examples
notepad++

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++?


Solution

    • 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