У меня есть файл json с массивом таких объектов:
[
{
"_index": "db",
"_type": "service",
"_id": "1",
"_score": 4.0,
"_source": {
"contentId": "1",
"title": "Sample 1",
"tokenizer": "whitespace",
"keyword": ["sample1", "service"],
"desp": "Desc this Service",
"contentType": "service",
"url": null,
"contentCategory": "Services",
"contentSubCategory": null,
"assignmentProfile": null,
"employeeId": null,
"assignmentProfileId": null,
"managedRuleId": null,
"contentAcademy": null,
"imageUrl": null,
"metaData": [
"sample1",
"services"
]
}
},
{
"_index": "db",
"_type": "service",
"_id": "2",
"_score": 7.0,
"_source": {
"contentId": "2",
"title": "Sample 2",
"tokenizer": "whitespace",
"keyword": ["sample2", "service"],
"desp": "Desc this Service",
"contentType": "service",
"url": null,
"contentCategory": "Services",
"contentSubCategory": null,
"assignmentProfile": null,
"employeeId": null,
"assignmentProfileId": null,
"managedRuleId": null,
"contentAcademy": null,
"imageUrl": null,
"metaData": [
"sample2",
"services"
]
}
}
]
Мне нужно удалить некоторые поля в этом. Все поля начинаются с полей _
и metadata
. Это должно закончиться так:
[
{
"contentId": "1",
"title": "Sample 1",
"tokenizer": "whitespace",
"keyword": ["sample1", "service"],
"desp": "Desc this Service",
"contentType": "service",
"url": null,
"contentCategory": "Services",
"contentSubCategory": null,
"assignmentProfile": null,
"employeeId": null,
"assignmentProfileId": null,
"managedRuleId": null,
"contentAcademy": null,
"imageUrl": null
},
{
"contentId": "2",
"title": "Sample 2",
"tokenizer": "whitespace",
"keyword": ["sample2", "service"],
"desp": "Desc this Service",
"contentType": "service",
"url": null,
"contentCategory": "Services",
"contentSubCategory": null,
"assignmentProfile": null,
"employeeId": null,
"assignmentProfileId": null,
"managedRuleId": null,
"contentAcademy": null,
"imageUrl": null
}
]
Я хочу написать выражение регулярного выражения в VSCode, чтобы сделать выше. Я написал следующее:
"metaData": \[\r\n (.+) ],
, чтобы заменить атрибут metaData пустой строкой. Но это не совпадает.
Размер массива составляет 100+, и, таким образом, есть выражение, чтобы сопоставить это с?