JSON Type
This article will teach you how to work with JSON data types with some useful examples.
Overview
JSON stands for JavaScript Object Notation. It is an open standard format that consists of key-value pairs to transport data between a server and a web application.
Syntax
The JSON data type in Oxla has the following syntax:
Examples
1) Create a Table
First, create the orders table using the below command:
For further details about JSON type, look at the examples below.
This will create a table with the orders_Detailcolumn to store key-value pairs of data.
2) Insert Data
Next, insert data into the orders table as follows:
This will insert data values where orders_Detailhas the following keys:
- customer: it will store a customer’s data who purchase the product.
- items: it will store the order details, product & qty.
3) Retrieve Data
Use the SELECTcommand to retrieve the orders table's data.
You will get the following output:
Note: It is normal for the JSON type’s result to look disordered.
