From 3263edca0eb5b5dfd60bf239f5d8b3163dd8ce1e Mon Sep 17 00:00:00 2001 From: mofelee Date: Thu, 17 Nov 2022 16:22:41 +0800 Subject: [PATCH] docs: add string to json array (#114) --- docs/jq.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/docs/jq.md b/docs/jq.md index b3ee7be..53404b7 100644 --- a/docs/jq.md +++ b/docs/jq.md @@ -229,6 +229,25 @@ $ echo '42' | jq '"The input was \(.), which is one less than \(.+1)"' ``` +### 字符串转 JSON 数组 + +```bash +$ echo 'a b c d' | jq -R 'split(" ")' +``` + + +输出结果 + +```json +[ + "a", + "b", + "c", + "d" +] +``` + + 另见 ----