# Using JSON Type

JSONB is a data type implemented in PostgreSQL aimed at enhancing the storage and manipulation of JSON data through improved efficiency and effectiveness when compared to the standard JSON data type.

JSONB stores JSON data in a binary form, enhancing indexing and query speed in comparison to the standard JSON data type. The utilization of binary format results in optimized storage and retrieval of JSON data, especially for handling extensive or intricate JSON entities.

#### Create JSONB Column

A table can be designed with a column assigned a data type of JSON or JSONB, similar to how columns are designated as Int, VARCHAR, or Double.

```plsql
CREATE TABLE journal (
  id Int NOT NULL PRIMARY KEY, day VARCHAR, 
  diary_information JSONB
);
```

#### Insert JSON data

```plsql
INSERT INTO journal (id, day, diary_information) 
VALUES 
  (
    1, “Tuesday”, '{"title": "My first day at work", "Feeling": "Nice place"}'
  );
```

#### JSON Functions and Operators <a href="#overview-of-json-functions-and-operators" id="overview-of-json-functions-and-operators"></a>

`->`: This operator allows you to extract a specific value from a JSON object, you specify the key as a “child” to the “parent”.

```plsql
SELECT 
  Id, 
  day, 
  diary_information -> 'Feeling' AS Feeling 
FROM 
  journal;
```

`->>`: This operator allows you to extract a JSON object field as text without the quotes around it from a JSON object.

```plsql
SELECT 
  id, 
  day, 
  dairy_information ->> 'Feeling' as Feeling 
FROM 
  products;
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.appizap.ae/database/table-schema/using-json-type.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
