{} (object construction)
On this page
Constructs an object from string keys and values of any type.
Syntax
{}
{<key>: <value>, ...}Arguments
| Argument | Type | Description |
|---|---|---|
<key> | string | Key expression. Pairs with a NULL key are skipped. |
<value> | Any type | Value associated with the key. NULL values are retained. |
Returns
Returns object. With no pairs, returns {}. Each key occurs once; if keys repeat, the last value is kept.
Examples
Build an object from request fields, with the status and duration grouped under outcome:
VALUES ('req-17', 'checkout', 504, 1200)
SELECT $0 AS request_id, $1 AS service, $2 AS status, $3 AS latency_ms
SELECT {
'request_id': request_id,
'outcome': {'status': status, 'latency_ms': latency_ms},
'context': {'service': service}
} AS findingThe finding value:
{
"context": {
"service": "checkout"
},
"outcome": {
"latency_ms": 1200,
"status": 504
},
"request_id": "req-17"
}