Yandex Cloud
Search
Discuss with expertTry it for free
  • Customer Stories
  • Documentation
  • Blog
  • All Services
  • System Status
  • Marketplace
    • Featured
    • Infrastructure & Network
    • Data Platform
    • AI for business
    • Security
    • DevOps tools
    • Serverless
    • Monitoring & Resources
  • All Solutions
    • By industry
    • By use case
    • Economics and Pricing
    • Security
    • Technical Support
    • Start testing with double trial credits
    • Cloud credits to scale your IT product
    • Gateway to Russia
    • Cloud for Startups
    • Center for Technologies and Society
    • Yandex Cloud Partner program
    • Price calculator
    • Pricing plans
  • Customer Stories
  • Documentation
  • Blog
© 2026 Direct Cursus Technology L.L.C.
Yandex Query
    • Overview
    • Selecting all columns
    • Selecting specific columns
    • Sorting and filtering
    • Data aggregation
    • Additional filter conditions
    • Working with JSON
    • Querying streaming data
  • Access management
  • Pricing policy
  • Integrations
  • Audit Trails events
  • FAQ
  1. Working with YQL
  2. Working with JSON

Working with JSON

Written by
Yandex Cloud
Improved by
Max Z.
Updated at July 7, 2026
View in Markdown

The JSON format is used for storing and processing data.

Basic JSON data operations:

  • Check if the name object exists.
  • Retrieve the age object’s value.
  • Request object data.
$json = CAST(@@{
    "friends": [
        {
            "name": "James Holden",
            "age": 35
        },
        {
            "name": "Naomi Nagata",
            "age": 30
        }
    ]
}@@ AS Json);

SELECT
    JSON_EXISTS($json, "$.friends[*].name"), -- Check if the `name` object exists
    JSON_VALUE($json, "$.friends[0].age"),   -- Retrieve the `age` object’s value
    JSON_QUERY($json, "$.friends[0]");       -- Request object data

Check the example in the right-hand section and click Run.
The query result will appear in the Result tab as a table or chart.

Escaping quotes in JSONEscaping quotes in JSON

Here is an example showing two ways to add a JSON string to a table:

UPSERT INTO test_json(id, json_string)
VALUES
    (1, Json(@@[{"name":"Peter \"strong cat\" Kourbatov"}]@@)),
    (2, Json('[{"name":"Peter \\\"strong cat\\\" Kourbatov"}]'))
;

To insert the first value, we use a raw string and escaping via \". To insert the second value, we use escaping via \\\".

We recommend using a raw string and escaping via \", as it is more readable.

Useful linksUseful links

  • SELECT operator
  • JSON_EXISTS function
  • JSON_VALUE function
  • JSON_QUERY function
  • Functions for JSON

Was the article helpful?

Previous
Additional filter conditions
Next
Querying streaming data
© 2026 Direct Cursus Technology L.L.C.