diff --git a/pkg/yqlib/doc/Entries.md b/pkg/yqlib/doc/Entries.md index faa74bbc..cac83f8f 100644 --- a/pkg/yqlib/doc/Entries.md +++ b/pkg/yqlib/doc/Entries.md @@ -98,7 +98,8 @@ KEY_a: 1 KEY_b: 2 ``` -Using with_entries is also useful whe you want to filter a map. Given a sample.yml file of: +## Use with_entries to filter the map +Given a sample.yml file of: ```yaml a: b: bird @@ -113,4 +114,5 @@ will output ```yaml a: b: bird -``` \ No newline at end of file +``` + diff --git a/pkg/yqlib/operator_entries_test.go b/pkg/yqlib/operator_entries_test.go index eb924458..2dad859a 100644 --- a/pkg/yqlib/operator_entries_test.go +++ b/pkg/yqlib/operator_entries_test.go @@ -53,11 +53,11 @@ var entriesOperatorScenarios = []expressionScenario{ }, }, { - description: "Use with_entries to filter keys", - document: `{a: b: "bird", c: d: "dog"}`, - expression: `with_entries(.value | has("b"))`, + description: "Use with_entries to filter the map", + document: `{a: { b: bird }, c: { d: dog }}`, + expression: `with_entries(select(.value | has("b")))`, expected: []string{ - "D0, P[], (!!map)::a:\n b: \"bird\"\n", + "D0, P[], (!!map)::a: {b: bird}\n", }, }, }