ConvertersLesson 34Free preview
SQL to JSON
This lesson is part of Web Developer Tools · All levels
Summary
The SQL to JSON converter converts the resulting line of a query or INSERT statement into an array of JSON objects. The column name is usually a key, while the value of each row is the object value. The number and boolean types are maintained when possible, while the NULL is mapped to the null. The converter works on SQL text or query results; it does not automatically connect to the database unless the tool supports the connection.
Key points
- Each line of the query results into one JSON object
- The column name becomes the key to the object
- NULL is mapped to null
- Strings must be properly escaped for JSON to be valid
- The result is an array of objects that are easy to use applications.
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.