Xbasic
argumentsToJSON Function
Syntax
C result = argumentsToJSON (argsOrArgsXML as A [, flagCompact as L ])
Arguments
- argsOrArgsXMLAny Type
Arguments - defined as a SQL::Arguments object or XML.
- flagCompactLogical
Default value is .f.. If .t., generated JSON will be generated without tabs or newlines.
Description
Serializes arguments to a JSON string.
Example
dim args as sql::Arguments
args.set("firstname","John")
args.set("lastname","Smith")
args.set("today",date())
? argumentstojson(args)
= [
{
name: 'firstname',
value: 'John',
type: 'C'
},
{
name: 'lastname',
value: 'Smith',
type: 'C'
},
{
name: 'today',
value: '10/31/2016',
type: 'D'
}
]
? argumentstojson(args, .t.)
= "[{name: 'firstname',value: 'John',type: 'C'},{name: 'lastname',value: 'Smith',type: 'C'},{name: 'today',value: '10/31/2016',type: 'D'}]"See Also