PINE LIBRARY
Updated jsonBuilder

Library "jsonBuilder"
jsonBuilder is a lightweight Pine Script utility library for building JSON strings manually. It includes functions to convert key-value pairs into JSON format and to combine multiple pairs into a complete JSON object.
jsonString(key, value) – Converts a string key and string value into a valid JSON key-value pair.
jsonObject(pair1, ..., pair20) – Merges up to 20 key-value pairs into a complete JSON object string. Empty arguments are skipped automatically.
This is useful when sending structured JSON data via webhooks or external integrations from Pine Script.
jsonBuilder is a lightweight Pine Script utility library for building JSON strings manually. It includes functions to convert key-value pairs into JSON format and to combine multiple pairs into a complete JSON object.
jsonString(key, value) – Converts a string key and string value into a valid JSON key-value pair.
jsonObject(pair1, ..., pair20) – Merges up to 20 key-value pairs into a complete JSON object string. Empty arguments are skipped automatically.
This is useful when sending structured JSON data via webhooks or external integrations from Pine Script.
Release Notes
v2// Create JSON key-value pairs
symbolKV = jsonBuilder.jsonString("symbol", syminfo.ticker)
priceKV = jsonBuilder.jsonString("price", str.tostring(close, "#.##"))
timeKV = jsonBuilder.jsonString("time", str.tostring(time))
// Combine pairs into a complete JSON object
json = jsonBuilder.jsonObject(symbolKV, priceKV, timeKV)
symbolKV = jsonBuilder.jsonString("symbol", syminfo.ticker)
priceKV = jsonBuilder.jsonString("price", str.tostring(close, "#.##"))
timeKV = jsonBuilder.jsonString("time", str.tostring(time))
// Combine pairs into a complete JSON object
json = jsonBuilder.jsonObject(symbolKV, priceKV, timeKV)
{
"symbol": "BTCUSD",
"price": "70823.45",
"time": "1713108494000"
}
"symbol": "BTCUSD",
"price": "70823.45",
"time": "1713108494000"
}
json = jsonBuilder.jsonObject(
jsonBuilder.jsonString("symbol", syminfo.ticker),
jsonBuilder.jsonString("price", str.tostring(close, "#.##")),
jsonBuilder.jsonString("time", str.tostring(time))
)
jsonBuilder.jsonString("symbol", syminfo.ticker),
jsonBuilder.jsonString("price", str.tostring(close, "#.##")),
jsonBuilder.jsonString("time", str.tostring(time))
)
{"symbol": "ETHUSD", "price": "3582.10", "time": "1713111120000"}
Pine library
In true TradingView spirit, the author has published this Pine code as an open-source library so that other Pine programmers from our community can reuse it. Cheers to the author! You may use this library privately or in other open-source publications, but reuse of this code in publications is governed by House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.
Pine library
In true TradingView spirit, the author has published this Pine code as an open-source library so that other Pine programmers from our community can reuse it. Cheers to the author! You may use this library privately or in other open-source publications, but reuse of this code in publications is governed by House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.