首页 > 解决方案 > 使用 jq 将 JSON 转换为纯文本

问题描述

假设我收到以下 json 响应:

{
  "author": "tomek",
  "title": "helloworld",
  "test": "sampletextonetwothree"
}

是否可以显示如下内容:(使用 jq)

author=tomek
title=helloworld
test=sampletextonetwothree

标签: jsonjq

解决方案


jq 'to_entries[] | "\(.key)=\(.value)"'

应该这样做


推荐阅读