Below you will find pages that utilize the taxonomy term “JSON”
How to query JSON in MySQL with JSON_CONTAINS
You can query a JSON document in MySQL to find content within it with:
- The
JSON_CONTAINS
function that will return if a JSON document is contained within another JSON document. The function returns1
if the document is contained,0
elsewhere. - The
JSON_CONTAINS
function that will return if a JSON document path is contained within another JSON document. The function returns1
if the document is contained,0
elsewhere.
How to load JSON data in PostgreSQL with the COPY command
You have a JSON dataset that you want to upload to a PostgreSQL table containing properly formatted rows and columns… How do you do it?
All the main sources like my own blog and others tell you to load the JSON in a dedicated temporary table containing a unique JSON
column, then parse it and load into the target table. However there could be another way, avoiding the temp table!
How to tabulate a JSON document in MySQL
You can tabulate a JSON document (retrieve it as a row) in MySQL with the JSON_TABLE
function.
How to remove a field in a JSON document in MySQL
You can remove a field from JSON document in MySQL with the JSON_REMOVE
function.
How to insert a field in a JSON document in MySQL
You can insert a field in a JSON document in MySQL with the JSON_INSERT
function.
How to edit a JSON document in MySQL
You can edit a JSON document in MySQL with:
- The
JSON_SET
function that will replace values for JSON paths that exists and add values for the ones that don’t exist. - The
JSON_REPLACE
function that will replace values for JSON paths that exists and ignore the ones that don’t exist.
How to merge JSON documents in MySQL
You can merge two JSON documents in MySQL with:
- the
JSON_MERGE_PRESERVE
function to concatenate the document values - the
JSON_MERGE_PATCH
function to keep the latest value for each key
How to create a JSON document from fields in MySQL
You can create a JSON document from fields in Mysql® with the JSON_OBJECT
function
How to get the JSON field types in MySQL
To get the type of a JSON item in MySQL you need to use the JSON_TYPE
function.
How to extract an item from an array in a JSON object in MySQL
To extract an item from an array in MySQL you need to use the ->
operator and the [item_number]
JSON Path Syntax.
How to extract a field from a JSON object in MySQL
MySQL® offers three ways to extract fields from a JSON object:
- the
->
operator to extract the field as JSON - the
->>
operator to extract the field as text - the
JSON_EXTRACT
function
Both operators use the JSON Path Syntax
How to load JSON data in MySQL?
To load JSON data into a MySQL column you need to include it as string.
How to JSON in MySQL
This series covers how to solve common problems on JSON datasets with MySQL and it includes (links will appear once the target pages are up):
How to load JSON data in PostgreSQL®?
PostgreSQL® offers two types of data types to handle JSON data, JSON
and JSONB
. This doc showcases how to load JSON data into a column.
How to tabulate a JSON to a record in PostgreSQL®
PostgreSQL® offers two types of data types to handle JSON data, JSON
and JSONB
, and provides two different ways to tabulate a JSON to a record:
How to tabulate a JSON to a recordset in PostgreSQL®
PostgreSQL® offers two types of data types to handle JSON data, JSON
and JSONB
, and provides two different ways to tabulate a JSON to a recordset:
How to edit a JSON object in PostgreSQL®?
PostgreSQL® offers two types of data types to handle JSON data, JSON
and JSONB
, you can use the jsonb_set
function to remove the null values for JSONB columns.
How to remove an item from a JSON array in PostgreSQL®?
PostgreSQL® offers two types of data types to handle JSON data, JSON
and JSONB
, you can use the -
operator to remove an item from an array.
How to remove fields from a JSON document in PostgreSQL®?
PostgreSQL® offers two types of data types to handle JSON data, JSON
and JSONB
, and provides two different ways to remove fields from a JSON document:
How to remove nulls JSON object in PostgreSQL®?
PostgreSQL® offers two types of data types to handle JSON data, JSON
and JSONB
, you can use the json_strip_nulls
(jsonb_strip_nulls
for JSONB) function to remove the null values.
How to concatenate two JSON documents in PostgreSQL®?
PostgreSQL® offers two types of data types to handle JSON data, JSON
and JSONB
, you can use the opearator ||
to concatenate two JSON objects.
How to create a JSON object from array of key/value pairs in PostgreSQL®?
PostgreSQL® offers two types of data types to handle JSON data, JSON
and JSONB
, you can use the function json_object
(jsonb_object
for JSONB
) to create a JSON object from an array of key/value pairs.
How to create a JSON object from keys and values arrays in PostgreSQL®?
PostgreSQL® offers two types of data types to handle JSON data, JSON
and JSONB
, you can use the function json_object
(jsonb_object
for JSONB
) to create a JSON object from two arrays of keys and values.
How to convert an array to a JSON array in PostgreSQL
PostgreSQL® offers two types of data types to handle JSON data, JSON
and JSONB
, you can use the function array_to_json
(array_to_jsonb
for JSONB
) to create a JSON array from an existing array.
How to build a JSON array from a list of elements in PostgreSQL®
PostgreSQL® offers two types of data types to handle JSON data, JSON
and JSONB
, you can use the function json_build_array
(jsonb_build_array
for JSONB
) to create a JSON array from a list of elements.
How to parse JSON keys in PostgreSQL®
PostgreSQL® offers two types of data types to handle JSON data, JSON
and JSONB
, you can use several functions to extract the keys and related values in tabular format.
How to convert a table row to JSON in PostgreSQL®?
PostgreSQL® offers two types of data types to handle JSON data, JSON
and JSONB
, you can use the function to_json
(to_jsonb
for JSONB
) to convert a table row to a JSON object.
How to prettify the JSON output in PostgreSQL®
PostgreSQL® offers two types of data types to handle JSON data, JSON
and JSONB
, you can use the function json_pretty
(jsonb_pretty
for JSONB
) to prettify the output.
How to parse JSON arrays in PostgreSQL?
PostgreSQL® offers two types of data types to handle JSON data, JSON
and JSONB
, and provides several different ways to parse arrays from a JSON document:
How to JSON in PostgreSQL®
This series covers how to solve common problems on JSON datasets with PostgreSQL® and it includes (links will appear once the target pages are up):
How to extract a field from a JSON object in PostgreSQL®?
PostgreSQL® offers two types of data types to handle JSON data, JSON
and JSONB
, and provides several different ways to extract fields from a JSON document:
How to get the JSON field types in PostgreSQL®?
PostgreSQL® offers two types of data types to handle JSON data, JSON
and JSONB
, you can use the function json_typeof
(jsonb_typeof
for JSONB
) to extract the fields type.
How to index and query a JSON object in PostgreSQL®?
PostgreSQL® offers two types of data types to handle JSON data, JSON
and JSONB
. This doc showcases how to index a JSONB
column with a GIN index.
How to check if JSON contains in PostgreSQL®?
PostgreSQL® offers two types of data types to handle JSON data, JSON
and JSONB
, and provides several different ways to check if a value/field from a JSON document:
What are the differences between JSON or JSONB in PostgreSQL®?
PostgreSQL® offers two types of data types to handle JSON data:
JSON
stores the JSON as text, performing a validation on the correctness of the JSON syntaxJSONB
optimizes the JSON storage in a custom binary format. Therefore, on top of validating the correctness of the JSON format, time is spent to properly parse and store the content.
Define a PostgreSQL database connection in JSON and import it in PGAdmin 4
How to define a database connection in a JSON file that can be imported in PG Admin 4