You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There are many cases when you need to convert an attribute name into values. What ma help is to have a keys() function that returns an array of keys.
Use Case 1:
Objects described in Json where ID of the object is the key need to be converted into an array of objects where ID is the property.
For example:
{
“a”: {"prop": "value1"},
“b”: {"prop": "value2"}
}
Convert to:
[
{“_id”: “a”, "prop": "value1"},
{“_id”: “b”, "prop": "value2"}
]
Use Case 2:
Key-value pairs need to be expanded to objects. And it should work for the arbitrary number of attributes.
For example:
{
“name”: "Milk",
“price”: 1
}
Convert to:
[
{“prop”: “name”, "value": "Milk"},
{“prop”: “price”, "value": 1}
]
The text was updated successfully, but these errors were encountered:
What about a function called entries(…) which turns an object{"a": "c"} into [{"key": "a", "value": "c"}? Your two examples would then be entries(foo) | { "_id": key, ...value } and entries(foo) | { "prop": key, value }.
entries() function may work. How it will behave on array?
Also, need to think if it will help in the following use case: [ [col1, col2], [val11, val12], [val21, val22] ]
to convert to: [ {col1: val11, col2: val12}, {col1: val11, col2: val12}, ]
There are many cases when you need to convert an attribute name into values. What ma help is to have a keys() function that returns an array of keys.
Use Case 1:
Objects described in Json where ID of the object is the key need to be converted into an array of objects where ID is the property.
For example:
{
“a”: {"prop": "value1"},
“b”: {"prop": "value2"}
}
Convert to:
[
{“_id”: “a”, "prop": "value1"},
{“_id”: “b”, "prop": "value2"}
]
Use Case 2:
Key-value pairs need to be expanded to objects. And it should work for the arbitrary number of attributes.
For example:
{
“name”: "Milk",
“price”: 1
}
Convert to:
[
{“prop”: “name”, "value": "Milk"},
{“prop”: “price”, "value": 1}
]
The text was updated successfully, but these errors were encountered: