Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SAP Sybase SQL Anywhere 16.0 » SQL Anywhere Server - SQL Usage » JSON in the database

 

Use of the FOR JSON clause to retrieve query results as JSON

SQL Anywhere allows you to execute a SQL query against your database and return the results as a JSON document by using the FOR JSON clause in a SELECT statement.

The FOR JSON clause can be used in any SELECT statement, including subqueries, queries with a GROUP BY clause or aggregate functions, and view definitions. Using the FOR JSON clause represents relational data as a JSON array composed of arrays, objects, and scalar elements.

Within the FOR JSON clause, you can specify one of the following JSON modes that control the format of the JSON that is generated:

  • RAW   returns query results as a flattened JSON representation. Although this mode is more verbose, it can be easier to parse.

  • AUTO   returns query results as nested JSON objects, based on query joins.

  • EXPLICIT   allows you to specify how column data is represented. You can specify columns as simple values, objects, or nested objects to produce uniform or heterogeneous arrays.

 See also