Skip to main content

JSON type

The JSON type allows you to store arbitrary JSON content, e.g. for use in Custom Code or to pass it on to external APIs.

info

Currently, there is no way to interact with the JSON content. We plan to add parse() functions to convert JSON content to objects, lists, etc.

JSON literal

To create a JSON value in a Hive rule, use the JSON literal:

json`{
"sku": "12345",
"color": "red",
"price": 19.99,
"tags": [
"clothing",
"sale",
"new"
],
"availability": {
"in_stock": true,
"quantity": 50
}
}`

Inside the backticks, you can write or paste raw JSON without having to make any formatting changes.

info

At present, there is no way to access components inside the JSON literal, but we plan to add an interpolation feature for this.

Usage

To store arbitrary JSON content, create a new ValueComponent with an Input or rule and use a JSON literal as fallback value:

Input or json`{}`

JSON values can also be part of typed objects, allowing you to create semi-structured models. For example, you can store a JSON value in an object passed to OnFinish.SetOutput:

OnFinish.SetOutput({
color: SelectedColor,
price: unitPrice * Amount,
pdfContext: if user.isLoggedIn then MyJsonComponent else json`{}` end
})