summaryrefslogtreecommitdiffhomepage
path: root/jq.html.markdown
diff options
context:
space:
mode:
authorJack Kuan <kjkuan@gmail.com>2022-06-02 00:54:50 -0400
committerJack Kuan <kjkuan@gmail.com>2022-06-02 00:54:50 -0400
commitf9b949fbf8980d4d47fabadcc6669425d41eb454 (patch)
tree65d9b7699bd8139f6c820d0ee706ce2bb071d954 /jq.html.markdown
parent52cc58a5edb34910a33e1daa328955c47c23e194 (diff)
Add parts missing due to copy&paste.
Diffstat (limited to 'jq.html.markdown')
-rw-r--r--jq.html.markdown31
1 files changed, 30 insertions, 1 deletions
diff --git a/jq.html.markdown b/jq.html.markdown
index 5aa03b91..31ce4d43 100644
--- a/jq.html.markdown
+++ b/jq.html.markdown
@@ -245,8 +245,37 @@ jq -n '[2*3, 8-1, 16/2], {("tw" + "o"): (1 + 1)}'
#
jq -n '{ key_1: "value1" }'
+# If a JSON object's key's value is ommited, it is looked up in the current
+# input using the key:
+#
+jq -n '{ c: 3} | { a: 1, "b", c }'
+
# Output:
-#
+# {
+# "a": 1,
+# "b": null,
+# "c": 3
+# }
+
+
+# jq programs are more commonly written as a series of expressions (filters)
+# connected by the pipe (`|`) operator, which makes the output of its left filter
+# the input to its right filter.
+#
+jq -n '1 | . + 2 | . + 3' # first dot is 1; second dot is 3
+
+# Output:
+# 6
+
+# If an expression evaluates to multiple outputs, then jq will iterate through
+# them and propagate each output down the pipeline, and generate multiple
+# outputs in the end.
+#
+jq -n '1, 2, 3 | ., 4 | .'
+
+# Output:
+# 1
+# 4
# 2
# 4
# 3