Skip to content

Commit

Permalink
Merge pull request #451 from bshifter/news-fx-keys
Browse files Browse the repository at this point in the history
news: filterx keys function
  • Loading branch information
bazsi authored Jan 9, 2025
2 parents 99c6ed2 + dd60768 commit 1be49da
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions news/fx-feature-435.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
`keys()`: Add keys Function to Retrieve Top-Level Dictionary Keys

This feature introduces the keys function, which returns the top-level keys of a dictionary. It provides a simple way to inspect or iterate over the immediate keys without manually traversing the structure.

- **Returns an Array of Keys**: Provides a list of dictionary keys as an array.
- **Current Level Only**: Includes only the top-level keys, ignoring nested structures.
- **Direct Index Access**: The resulting array supports immediate indexing for quick key retrieval.

**Example**:

```python
dict = {"foo":{"bar":{"baz":"foobarbaz"}},"tik":{"tak":{"toe":"tiktaktoe"}}};
# empty dictionary returns []
empty = keys(json());

# accessing the top level results ["foo", "tik"]
a = keys(dict);

# acccessing nested levels directly results ["bar"]
b = keys(dict["foo"]);

# directly index the result of keys() to access specific keys is possible (returns ["foo"])
c = keys(dict)[0];
```

0 comments on commit 1be49da

Please sign in to comment.