PINE LIBRARY
업데이트됨 JSON_Converter

Library "JSON_Converter"
In case you're having trouble writing .JSON strings for your TV alerts simply import this Library and use the following functions:
get_attributes(attribute_name, values)
parses an arrays of floats and a string into a .JSON attribute - This attribute itself is not a valid .JSON string. If you want to use it you have to call this librarys .parse function with an array containing the return value of this function
Parameters:
attribute_name (string): (string): the name of this attribute in your JSON. In the final JSON it can be called with .<attribute_name>
values (float[]): (float[]): an array of all the float (includes int) values that you want to give this attribute
Returns: a string in the following form: "<attribute_name>":[<value1>,<value2>,...]
parse(attributes)
parses an arrays of strings - consisting of already parsed attributes - into a valid .JSON format
Parameters:
attributes (string[]): (string[]): an array containing all the attributes that you got by calling .get_attributes(...) with your data
Returns: a string in .JSON format that includes all your already parsed attributes
parse(values)
parses a simple float array into a JSON string containing only a float array
Parameters:
values (float[]): (float[]): an array containing all the values that you want your simple JSON to contain
Returns: a string in .JSON format that includes all your values in an an array. This array has whatever name you gave it when calling the parse(data.contents) function after catching the TV alert
Depending on what you want you JSON to look like you can either use the first two functions (get_attributes(attribute_name, values) and parse(attributes)) together to get a more complex JSON or use the last function (parse(values)) which only takes an array of floats so nothing fancy or complex.
Example on how to use:
Pine Script®
In case you're having trouble writing .JSON strings for your TV alerts simply import this Library and use the following functions:
get_attributes(attribute_name, values)
parses an arrays of floats and a string into a .JSON attribute - This attribute itself is not a valid .JSON string. If you want to use it you have to call this librarys .parse function with an array containing the return value of this function
Parameters:
attribute_name (string): (string): the name of this attribute in your JSON. In the final JSON it can be called with .<attribute_name>
values (float[]): (float[]): an array of all the float (includes int) values that you want to give this attribute
Returns: a string in the following form: "<attribute_name>":[<value1>,<value2>,...]
parse(attributes)
parses an arrays of strings - consisting of already parsed attributes - into a valid .JSON format
Parameters:
attributes (string[]): (string[]): an array containing all the attributes that you got by calling .get_attributes(...) with your data
Returns: a string in .JSON format that includes all your already parsed attributes
parse(values)
parses a simple float array into a JSON string containing only a float array
Parameters:
values (float[]): (float[]): an array containing all the values that you want your simple JSON to contain
Returns: a string in .JSON format that includes all your values in an an array. This array has whatever name you gave it when calling the parse(data.contents) function after catching the TV alert
Depending on what you want you JSON to look like you can either use the first two functions (get_attributes(attribute_name, values) and parse(attributes)) together to get a more complex JSON or use the last function (parse(values)) which only takes an array of floats so nothing fancy or complex.
Example on how to use:
import Marius_S/JSON_Converter/1 as JSON
a = "a"
b = "b"
c = "c"
values_a = array.from(1, na, 3)
values_b = array.from(4, 5)
values_c = array.from(6, 7, 8, 9)
a_ = JSON.get_attributes(a, values_a)
b_ = JSON.get_attributes(b, values_b)
c_ = JSON.get_attributes(c, values_c)
json = JSON.parse(array.from(a_, b_, c_))
// returns: "{"a":[1,"NaN",3],"b":[4,5],"c":[6,7,8,9]}"
릴리즈 노트
v2 - includes get_attributes() functions for strings and boolean values Updated:
get_attributes(attribute_name, bools)
parses an arrays of bools and a string into a .JSON attribute - This attribute itself is not a valid .JSON string. If you want to use it you have to call this librarys .parse function with an array containing the return value of this function
Parameters:
attribute_name (string): (string): the name of this attribute in your JSON. In the final JSON it can be called with .<attribute_name>
bools (array<bool>)
Returns: a string in the following form: "attribute_name":[value1,value2,...] - boolean values will be transformed into strings for json validity
파인 라이브러리
진정한 트레이딩뷰 정신에 따라 작성자는 이 파인 코드를 오픈 소스 라이브러리로 공개하여 커뮤니티의 다른 파인 프로그래머들이 재사용할 수 있도록 했습니다. 작성자에게 건배! 이 라이브러리는 개인적으로 또는 다른 오픈 소스 출판물에서 사용할 수 있지만, 출판물에서 이 코드를 재사용하는 것은 하우스 룰의 적용을 받습니다.
면책사항
이 정보와 게시물은 TradingView에서 제공하거나 보증하는 금융, 투자, 거래 또는 기타 유형의 조언이나 권고 사항을 의미하거나 구성하지 않습니다. 자세한 내용은 이용 약관을 참고하세요.
파인 라이브러리
진정한 트레이딩뷰 정신에 따라 작성자는 이 파인 코드를 오픈 소스 라이브러리로 공개하여 커뮤니티의 다른 파인 프로그래머들이 재사용할 수 있도록 했습니다. 작성자에게 건배! 이 라이브러리는 개인적으로 또는 다른 오픈 소스 출판물에서 사용할 수 있지만, 출판물에서 이 코드를 재사용하는 것은 하우스 룰의 적용을 받습니다.
면책사항
이 정보와 게시물은 TradingView에서 제공하거나 보증하는 금융, 투자, 거래 또는 기타 유형의 조언이나 권고 사항을 의미하거나 구성하지 않습니다. 자세한 내용은 이용 약관을 참고하세요.