Вот альтернативный подход с использованием Unix-утилиты, основанной на дорожке пути. jtc
:
- Я взял на себя смелость, добавив в исходные примеры JSON еще 4 "type": "standard"
записи, но отобразив только первые 3 (для демонстрации):
bash $ <file.json jtc -r
{ "dashboards": [ { "name": "first", "type": "standard" }, { "name": "second", "type": "custom" }, { "name": "second", "type": "standard" }, { "name": "third", "type": "standard" }, { "name": "fifth", "type": "standard" } ] }
bash $
bash $
bash $ <file.json jtc -w'[type]:<standard>:3 [-1]'
{
"name": "first",
"type": "standard"
}
{
"name": "second",
"type": "standard"
}
{
"name": "third",
"type": "standard"
}
bash $
PS> Раскрытие информации: я создатель jtc
инструмента