-
Notifications
You must be signed in to change notification settings - Fork 103
Open
Description
I was trying to compose an array of objects, adding a property and kept getting errors, until I randomly tried $. and everything worked.
Couldn't find mentions in the docs about $. though.
Input:
{
"state": [
{
"text": "one",
"data": [ -1, -2, -3 ]
},
{
"text": "two",
"data": [ 4, 5, 6 ]
}
],
"metadata": {
"title": "something" // <=== static value to use
}
}Output desired:
[
{
"x": "one",
"y": [ -1, -2, -3 ],
"title": "something" // <=== static value outside the arrays
},
{
"x": "two",
"y": [ 4, 5, 6 ],
"title": "something" // <=== static value outside the arrays
}
]Attempts:
state[].{ x: text, y: data, title: metadata.title } => title is null (see below)
state[].{ x: text, y: data, title: `metadata.title` } => syntax error
state[].{ x: text, y: data, title: $metadata.title } => Error referencing undefined variable metadata
state[].{ x: text, y: data, title: $.metadata.title } => ** SUCCESS **
Result when using state[].{ x: text, y: data, title: metadata.title }
[
{
"x": "one",
"y": [ -1, -2, -3 ],
"title": null
},
{
"x": "two",
"y": [ 4, 5, 6 ],
"title": null
}
]Metadata
Metadata
Assignees
Labels
No labels