Xbasic
SQL::ConnectionresultSetFromJSON Method
Syntax
dim result as SQL::ResultSet = resultSetFromJSON(json as C [, ti as SQL::TableInfo [, alias as C]])
Arguments
- JSONCharacter
A string containing a JSON array of objects representing the table.
- tiSQL::TableInfo
An optional supplied table schema.
- aliasCharacter
Alias name for table.
Returns
- resultSQL::ResultSet
Returns a SQL::ResultSet that can be used to iterate over the records in the JSON array.
Description
Create a SQL::ResultSet from JSON.
Discussion
The .resultSetFromJSON() SQL::Connection method creates a SQL::ResultSet from JSON and an optional table info (schema). This function uses the Extension::JSON toResultSet() method internally to convert the JSON to a SQL::ResultSet.
Example
dim json as c = <<%json%
[
{"ID":"1","Company":"Company A","Last_Name":"Bedecs","First_Name":"Anna"},
{"ID":"2","Company":"Company B","Last_Name":"Solsona","First_Name":"Antonio"},
{"ID":"3", "Company":"Company C", "Last_Name":"Axen","First_Name":"Thomas"}
]
%json%
dim rs as sql::ResultSet
dim cn as sql::connection
rs = cn.ResultSetFromJSON(json)
sql_resultset_preview(rs)See Also