PINE LIBRARY
Cập nhật

jsonBuilder

374
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à ấn phẩm không có nghĩa là và không cấu thành, tài chính, đầu tư, kinh doanh, hoặc các loại lời khuyên hoặc khuyến nghị khác được cung cấp hoặc xác nhận bởi TradingView. Đọc thêm trong Điều khoản sử dụng.