From f3b6e2808e5a087594d7214d1abc4805ac3cbcde Mon Sep 17 00:00:00 2001 From: Stephen Dolan Date: Mon, 22 Oct 2012 22:56:39 +0100 Subject: [PATCH] docs update --- download/index.html | 2 +- manual/index.html | 103 ++++++++++++++++++++++++++++++-------------- tutorial/index.html | 2 +- 3 files changed, 72 insertions(+), 35 deletions(-) diff --git a/download/index.html b/download/index.html index 792a5860..f488da7c 100644 --- a/download/index.html +++ b/download/index.html @@ -58,7 +58,7 @@ diff --git a/manual/index.html b/manual/index.html index 1bea5517..b422c01c 100644 --- a/manual/index.html +++ b/manual/index.html @@ -123,6 +123,8 @@ "`length`" : "length", + "`keys`" : "keys", + "`map(x)`" : "mapx", "`add`" : "add", @@ -131,7 +133,7 @@ "`tostring`" : "tostring", - "String interpolation - `@(text)`" : "Stringinterpolationtext", + "String interpolation - `\\(foo)`" : "Stringinterpolationfoo", "Builtin operators and functions" : "Builtinoperatorsandfunctions" , @@ -982,6 +984,45 @@ +
+

+

keys

+ +

+

The builtin function keys, when given an object, returns its keys in an array.

+ +

The keys are sorted “alphabetically”, by unicode codepoint order. This is not an order that makes particular sense in any particular language, but you can count on it being the same for any two objects with the same set of keys, regardless of locale settings.

+ + +
+ + + + Example + +
+ + + + + + + + + + + + + + + +
jq 'keys'
Input{"abc": 1, "abcd": 2, "Foo": 3}
Output["Foo", "abc", "abcd"]
+ +
+
+ +
+

map(x)

@@ -994,11 +1035,11 @@
- + Example -
+
@@ -1033,11 +1074,11 @@
@@ -1100,11 +1141,11 @@
@@ -1137,11 +1178,11 @@
@@ -1178,29 +1219,25 @@ -
+

-

String interpolation - @(text)

+

String interpolation - \(foo)

-

jq supports an alternative syntax for strings. Instead of “foo”, you can write @(foo). When using this syntax, %(expression) may be used to insert the value of expression into the string (converted with tostring).

- -

String interpolation does not occur for normal double-quoted strings (like "foo") in order to be fully compatible with JSON.

- -

All of the usual JSON escapes (\n, \r and the like) work inside @()-quoted strings, as well as \% and \) if those characters are needed literally.

+

Inside a string, you can put an expression inside parens after a backslash. Whatever the expression returns will be interpolated into the string.

- + @@ -1237,11 +1274,11 @@
jq '@(The input was %(.), which is one less than %(.+1))'
jq '"The input was \(.), which is one less than \(.+1)"'
Input42
@@ -1280,11 +1317,11 @@
@@ -1330,11 +1367,11 @@ not.

@@ -1442,11 +1479,11 @@ not.

@@ -1540,11 +1577,11 @@ not.

@@ -1591,11 +1628,11 @@ not.

@@ -1685,11 +1722,11 @@ not.

diff --git a/tutorial/index.html b/tutorial/index.html index e7501e1a..fdf67ad8 100644 --- a/tutorial/index.html +++ b/tutorial/index.html @@ -53,7 +53,7 @@

Tutorial

-

Twitter have a JSON API, so let’s play with that. This URL gets us the last 5 tweets about JSON:

+

Twitter has a JSON API, so let’s play with that. This URL gets us the last 5 tweets about JSON: