From 89545ea9d0c2cf5c7a7e9dba1ace98b0f7a3dfa5 Mon Sep 17 00:00:00 2001 From: Adam Lindberg Date: Fri, 1 Aug 2014 12:13:35 +0200 Subject: [PATCH] Add example of selecting object with keys It is not very straight forward how to select objects by their attributes from an array. This example provides the basic use case of how to select some objects based key values. --- docs/content/3.manual/manual.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/content/3.manual/manual.yml b/docs/content/3.manual/manual.yml index 6522a6a0..a651373d 100644 --- a/docs/content/3.manual/manual.yml +++ b/docs/content/3.manual/manual.yml @@ -708,6 +708,9 @@ sections: - program: 'map(select(. >= 2))' input: '[1,5,3,0,7]' output: ['[5,3,7]'] + - program: '.[] | select(.id == "second")' + input: '[{"id": "first", "val": 1}, {"id": "second", "val": 2}]' + output: '{"id": "second", "val": 2}' - title: "`arrays`, `objects`, `iterables`, `booleans`, `numbers`, `strings`, `nulls`, `values`, `scalars`"