Skip to content

bigfunctions > items2json

items2json

Signature

items2json(key_value_items)

Description

Returns json object from array of key_value_items which is a array<struct<key string, value string>>.

Examples

select bigfunctions.eu.items2json([('a', 'foo'), ('b': 'bar')])
select bigfunctions.us.items2json([('a', 'foo'), ('b': 'bar')])
select bigfunctions.europe_west1.items2json([('a', 'foo'), ('b': 'bar')])
+--------------------------+
| json                     |
+--------------------------+
| {"a": "foo", "b": "bar"} |
+--------------------------+

2. ⚠️ Whatever the names of the struct fields: the first field is always considered as the key and the second as the value.

select bigfunctions.eu.items2json([struct('a' as value, 'foo' as key), struct('b' as one, 'bar' as two)])
select bigfunctions.us.items2json([struct('a' as value, 'foo' as key), struct('b' as one, 'bar' as two)])
select bigfunctions.europe_west1.items2json([struct('a' as value, 'foo' as key), struct('b' as one, 'bar' as two)])
+--------------------------+
| json                     |
+--------------------------+
| {"a": "foo", "b": "bar"} |
+--------------------------+