Xbasic
json_to_crlf Function
Syntax
json_to_crlf as c (json as c [, flagSilent as l [,delimiter as c]])
Arguments
- jsonCharacter
A JSON array.
- flagSilentLogical
Default = .t.. If set to .f., a message box will be displayed if an error occurs while parsing the JSON.
- delimiterCharacter
Default = "|". The separator used between each field value in a row.
Returns
- resultCharacter
Returns the JSON formatted as a CR-LF delimited string where each field is separated by the delimiter.
Description
Convert json to crlf data.
Discussion
The json_to_crlf() converts a JSON array into a CR-LF delimited string of data. The first row in the returned string is the list of field names. Each field is separated by the specified delimiter.
Example
dim json as c=<<%json%
[
{"firstname":"Susan","lastname":"Sparks"},
{"firstname":"Karen","lastname":"Smith"},
{"firstname":"Joe","lastname":"Evans"},
{"firstname":"Janette","lastname":"McNally"}
]
%json%
? json_to_crlf(json)
= firstname|lastname
Susan|Sparks
Karen|Smith
Joe|Evans
Janette|McNally