PINE LIBRARY
Telah dikemas kini

jsonBuilder

123
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.
Nota Keluaran
v2

Pine Script®
// 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)

Pine Script®
{ "symbol": "BTCUSD", "price": "70823.45", "time": "1713108494000" }

Pine Script®
json = jsonBuilder.jsonObject( jsonBuilder.jsonString("symbol", syminfo.ticker), jsonBuilder.jsonString("price", str.tostring(close, "#.##")), jsonBuilder.jsonString("time", str.tostring(time)) )

Pine Script®
{"symbol": "ETHUSD", "price": "3582.10", "time": "1713111120000"}

Penafian

Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.