Library "json" Convert JSON strings to tradingview ▦ FEATURES ▦ █ Json to array █ Get json key names █ Get json key values █ Size of json
get_json_keys_names(raw_json) Returns string array with all key names Parameters: raw_json: (string) Raw JSON string Returns: (string array) Array with all key names
get_values_by_id_name(raw_json, key_name) Returns string array with values of the input key name Parameters: raw_json: (string) Raw JSON string key_name: (string) Name of the key to be fetched Returns: (string array) Array with values of the input key name
size_of_json_string(raw_json) Returns size of raw JSON string [n_of_values, n_of_keys_names] Parameters: raw_json: (string) Raw JSON string Returns: [int, int] Size of n_of_values, size of n_of_keys_names
I got empty string when using this, can I have an example of putting the inputs ?
MA_PT
⋅
@BeeInvested, Hi ticker.heikinashi(symbol) → simple string The function you used returns a simple, the json library is targeted to read JSON structure. In your example, there's no JSON structure therefore returns "null"
Here's an example: Where it returns the names of the available JSON from input and displays them in a table. Note: You can play around with the input
I'm new and try to learning Pine Script and i have a question about JSON.
i write this message and i want to send via Webhock to Python Server als JSON but it doesn't work
ticker = syminfo.ticker
position = array.from(message)
T1 = str.tostring(startPrice)
E1 = startPrice + diff * -0.27
E2 = startPrice + diff * -0.414
E3 = startPrice + diff * -0.618
SL = startPrice + diff * -0.786
if Short or Long
//values = array.from(str.tostring(ticker), str.tostring(message), str.tostring(E1), str.tostring(T1), str.tostring(E2), str.tostring(E1), str.tostring(E3), str.tostring(E2), str.tostring(SL))
//alertMessage = ra.updateAlertTemplate(template, keys, values)
Tmessage = '{"Ticker":"'+str.tostring(syminfo.ticker)+'",'+
//'"Position":'+str.tostring(message)+','+
'"Position":"'+str.tostring(message)+'",'+
'"Entry 1":"'+str.tostring(E1)+'",'+
'"Target 1":'+str.tostring(T1)+','+
'"Entry 2":'+str.tostring(E2)+','+
'"Target 2":'+str.tostring(E1)+','+
'"Entry 3":'+str.tostring(E3)+','+
'"Target 3":'+str.tostring(E2)+','+
'"Stop Lost":'+str.tostring(SL)+
'}'
alert(Tmessage, alert.freq_once_per_bar_close)
and it is my Error: "argument of type 'NoneType' is not iterable"
Could you held me?