From 794d29a4309c421f8d6169328d082c8950e5b9b6 Mon Sep 17 00:00:00 2001 From: Stephen Dolan Date: Mon, 22 Oct 2012 22:56:56 +0100 Subject: [PATCH] Docs fixes. - Mention homebrew on download page (#25) - Document 'keys' and string interpolation --- docs/content/2.download/default.yml | 1 + docs/content/3.manual/manual.yml | 36 ++++++++++++++++++----------- 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/docs/content/2.download/default.yml b/docs/content/2.download/default.yml index 54f4d78..d1deb30 100644 --- a/docs/content/2.download/default.yml +++ b/docs/content/2.download/default.yml @@ -9,6 +9,7 @@ body: * [Download binary for 64-bit Linux](linux_x86_64/jq) * [Download binary for OS X](osx_64/jq) + (or use [homebrew](http://mxcl.github.com/homebrew/): `brew install jq`) * [Download source](source/jq.tgz) The binaries should just run, but you may need to make them diff --git a/docs/content/3.manual/manual.yml b/docs/content/3.manual/manual.yml index 4ec88c2..9039caf 100644 --- a/docs/content/3.manual/manual.yml +++ b/docs/content/3.manual/manual.yml @@ -373,6 +373,23 @@ sections: input: '[[1,2], "string", {"a":2}, null]' output: [2, 6, 1, 0] + - title: `keys` + body: | + + 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. + + examples: + - program: 'keys' + input: '{"abc": 1, "abcd": 2, "Foo": 3}' + output: ['["Foo", "abc", "abcd"]'] + - title: `map(x)` body: | @@ -434,24 +451,15 @@ sections: input: '[1, "1", [1]]' output: ['"1"', '"1"', '"[1]"'] - - title: "String interpolation - `@(text)`" + - title: "String interpolation - `\(foo)`" body: | - 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. examples: - - program: '@(The input was %(.), which is one less than %(.+1))' + - program: '"The input was \(.), which is one less than \(.+1)"' input: '42' output: ['"The input was 42, which is one less than 43"'] -- 2.40.0