DELETE THE TAGS THAT ARE NOT APPLICABLE TO THIS FUNCTION AND THEN DELETE THIS COMMENT AND ADD THE VERSION NUMBER (LAST ITEM IN TAG LIST) THAT INTRODUCES THE FUNCTION
{{tag>Function Function_List Miscellaneous version:v9.0}}
====== LIST_TO_JSON ======
===== Description =====
Converts a list of business objects into a JSON string. Specified attributes of each list member are printed out.
===== Syntax =====
''LIST_TO_JSON (list[, order], attribute[, attribute...])''
===== Parameters =====
- A list to print out or a query finding business objects to print
- If a list is specified an additional parameter can be optionally specified to contain sorting criteria in the Rule Language format.
- Second, third, fourth and other parameters - attribute specification to include in JSON.
- Attribute specification consists of an attribute name, optionally followed by a JSON name and format separated by @ delimiter.
- If an attribute name starts with the # symbol the content of the attribute value is already a JSON formatted string which just needs to be inserted.
===== Returns =====
**Text**: the list members' chosen attributes converted to a JSON string.
===== Example =====
LIST_TO_JSON (Client.Children, 'ORDER BY Client.Name DESC', 'FirstName', 'LastName', 'Age', 'ID@My id', 'Date@Date@MMM dd yyyy')
This produces the following string:
{
"FirstName": "Jane",
"LastName" : "Allison",
"Age" : 15,
"My id" : "some value",
"Date": "Jan 2 2024"
},
{
"FirstName": "Bob",
"LastName" : "Fisk",
"Age" : 30,
"My id" : "some other value",
"Date": "Feb 12 2024"
}
...
===== Related =====
[[ref:a_f:f:af:parse_json|PARSE_JSON]], [[ref:a_f:f:af:parse_json2|PARSE_JSON2]], [[ref:a_f:f:af:list|LIST]], [[ref:a_f:f:af:list_line|LIST_LINE]]