+
-
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.
-
+
Example
-
+
- | jq '@(The input was %(.), which is one less than %(.+1))' |
+ | jq '"The input was \(.), which is one less than \(.+1)"' |
| Input | 42 |
@@ -1237,11 +1274,11 @@
-
+
Example
-
+
@@ -1280,11 +1317,11 @@
-
+
Example
-
+
@@ -1330,11 +1367,11 @@ not.
-
+
Examples
-
+
@@ -1442,11 +1479,11 @@ not.
-
+
Examples
-
+
@@ -1540,11 +1577,11 @@ not.
-
+
Example
-
+
@@ -1591,11 +1628,11 @@ not.
-
+
Examples
-
+
@@ -1685,11 +1722,11 @@ not.
-
+
Example
-
+
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: