Read and parse JSON in SQL / Teradata

access_time 2 years ago visibility807 comment 0

JSON is commonly used in modern applications for data storage and transfers. Pretty much all programming languages provide APIs to parse JSON. 

From Teradata version 15.0, JSON shredding functions are added. JSONExtractValue function can be used to extract JSON data from JSON object.  NEW JSON can be used to convert string to JSON object. 

In Teradata JSON native data type is also supported. Shredding functions allow you to extract vJSON documents up to 16MB in size. 

Code snippet

SELECT jsonObj.Name AS Name,
    jsonObj.JSONExtractValue('$.Value') AS "Value"
    FROM
    (
    SELECT NEW json('{"Name":"A","Value":2}') AS jsonObj) AS r;
info Last modified by Raymond 2 years ago copyright This page is subject to Site terms.
Like this article?
Share on

Please log in or register to comment.

account_circle Log in person_add Register

Log in with external accounts

Follow Kontext

Get our latest updates on LinkedIn or Twitter.

Want to publish your article on Kontext?

Learn more

More from Kontext

visibility 738
thumb_up 0
access_time 6 months ago

This page shows how to create, drop, and truncate Hive tables via Hive SQL (HQL). Refer to  Differences between Hive External and Internal (Managed) Tables to understand the differences between managed and unmanaged tables in Hive.  Example: CREATE TABLE IF NOT EXISTS ...

visibility 10
thumb_up 0
access_time 30 days ago

Teradata BIGINT data type represents a signed, binary integer value from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807. To convert BIGINT to VARCHAR data type, CAST function can be used directly.  SEL CAST(-9223372036854775808 AS VARCHAR(100)) Result:  ...

visibility 807
thumb_up 2
access_time 2 years ago

JSON is commonly used in modern applications for data storage and transfers. Pretty much all programming languages provide APIs to parse JSON.