Document to_entries support for arrays (#3712)
Mention in the manual that to_entries also accepts an array, using the index of each element as its key, and add an example.
This commit is contained in:
1 parent
3e208ae2b6
commit
f0c3c68e1e
3 files changed
+17
No files matched your search
@@ -1181,10 +1181,16 @@ sections:
|
||||
`from_entries` accepts `"key"`, `"Key"`, `"name"`, `"Name"`,
|
||||
`"value"`, and `"Value"` as keys.
|
||||
|
||||
`to_entries` also accepts an array, using the index of each
|
||||
element as its `key`.
|
||||
|
||||
examples:
|
||||
- program: 'to_entries'
|
||||
input: '{"a": 1, "b": 2}'
|
||||
output: ['[{"key":"a", "value":1}, {"key":"b", "value":2}]']
|
||||
- program: 'to_entries'
|
||||
input: '["a", "b", "c"]'
|
||||
output: ['[{"key":0,"value":"a"}, {"key":1,"value":"b"}, {"key":2,"value":"c"}]']
|
||||
- program: 'from_entries'
|
||||
input: '[{"key":"a", "value":1}, {"key":"b", "value":2}]'
|
||||
output: ['{"a": 1, "b": 2}']
|
||||
|
||||
Reference in new issue
Block a user