如何使用bash转换/格式化json字符串

时间:2020-04-03 19:15:11

标签: json bash

我有以下string

"{\n  \"type\": \"service_account\",\n  \"project_id\": \"my-project-123\",\n  \"time\": \"23:00:22.23124\"\n  }"

我想要这样的格式JSON

{
    "type":"service_account",
    "project_id":"my-project-123",
    "time":"23:00:22.23124"
}

1 个答案:

答案 0 :(得分:1)

-e选项可以在字符串中扩展\n

echo -e "put your string here"