Skip to content

Instantly share code, notes, and snippets.

@DennisXie
Created June 14, 2018 08:04
Show Gist options
  • Save DennisXie/e6f4a70ec8970d55294fa4e55e94b799 to your computer and use it in GitHub Desktop.
Save DennisXie/e6f4a70ec8970d55294fa4e55e94b799 to your computer and use it in GitHub Desktop.
jq: list to object
问题: 使用jq将[{uid: 1, k1: v1, k2: v2}, {uid: 2, k1: v1, k2: v2}, ....]的list转换成 {'1': {k1: v1, k2: v2}, '2': {k1: v1, k2: v2},.....}这种形式
jq: [.[] | {(.uid | tostring): {k1: .k1, k2: .k2}}] | add
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment