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:
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
Pine Bibliothek
Ganz im Sinne von TradingView hat dieser Autor seinen/ihren Pine Code als Open-Source-Bibliothek veröffentlicht. Auf diese Weise können nun auch andere Pine-Programmierer aus unserer Community den Code verwenden. Vielen Dank an den Autor! Sie können diese Bibliothek privat oder in anderen Open-Source-Veröffentlichungen verwenden. Die Nutzung dieses Codes in einer Veröffentlichung wird in unseren Hausregeln reguliert.
Haftungsausschluss
Pine Bibliothek
Ganz im Sinne von TradingView hat dieser Autor seinen/ihren Pine Code als Open-Source-Bibliothek veröffentlicht. Auf diese Weise können nun auch andere Pine-Programmierer aus unserer Community den Code verwenden. Vielen Dank an den Autor! Sie können diese Bibliothek privat oder in anderen Open-Source-Veröffentlichungen verwenden. Die Nutzung dieses Codes in einer Veröffentlichung wird in unseren Hausregeln reguliert.