С помощью утилиты jq.
Установка в windows с помощью chocolatey
choco i -y jq
Форматирование json
echo '{"foo": "lorem", "bar": "ipsum"}' | jq
# или
echo '{"foo": "lorem", "bar": "ipsum"}' | jq '.'
Результат
{
"foo": "lorem",
"bar": "ipsum"
}
Или можно натравить на curl запрос
curl -sSL -X GET "https://httpbin.org/json" -H "accept: application/json" | jq
{
"slideshow": {
"author": "Yours Truly",
"date": "date of publication",
"slides": [
{
"title": "Wake up to WonderWidgets!",
"type": "all"
},
{
"items": [
"Why <em>WonderWidgets</em> are great",
"Who <em>buys</em> WonderWidgets"
],
"title": "Overview",
"type": "all"
}
],
"title": "Sample Slide Show"
}
}
Преобразование [{ "a": "a" }, { "b": "b" }]
в { "a": "a", "b": "b" }
echo '[{ "a": "a" }, { "b": "b" }]' | jq add