PINE LIBRARY
Cập nhật

jsonBuilder

486
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.
Phát hành các Ghi chú
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"}

Thông báo miễn trừ trách nhiệm

Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.