

Every sales dashboard, marketing funnel, or customer journey you care about is now fed by JSON: event payloads from your product, ad platform logs, CRM webhooks. Snowflake is where all of that lands.
Using PARSE_JSON in Snowflake lets you turn those raw payloads into a flexible VARIANT column, then project out clean ARRAY and OBJECT structures you can query with simple dot or bracket notation. You get schema-on-read, so when an ad platform adds a new field tomorrow, your warehouse does not collapse. TRY_PARSE_JSON protects long-running loads from bad rows by returning NULL instead of errors, and LATERAL FLATTEN turns deeply nested arrays into analysis-ready tables.
This is where an AI computer agent becomes more than a convenience. Instead of your team hand-writing the same parsing patterns for every source, the agent can open worksheets, paste or adapt templates, run tests, and standardize PARSE_JSON and FLATTEN logic across dozens of tables. While it works through the repetitive SQL and UI clicks, your analysts stay focused on questions like “Which campaigns actually convert?” rather than “Why did this JSON key throw an error again?”.
Before we bring in automation or agents, it helps to master the core primitives Snowflake gives you for JSON. Think of these as the building blocks your team – and your AI agent – will reuse.
CREATE OR REPLACE TABLE events_raw (
id STRING,
payload VARIANT
);
PARSE_JSON on the raw string:INSERT INTO events_raw (id, payload)
SELECT
$1 AS id,
PARSE_JSON($2) AS payload
FROM @my_stage/raw_events;
payload is a JSON document in VARIANT form. You can query it with payload:customer.id or payload['event_type'].Official docs: PARSE_JSON.
Bad rows from webhooks or malformed logs can crash a whole load.
PARSE_JSON for TRY_PARSE_JSON:INSERT INTO events_raw (id, payload)
SELECT
$1,
TRY_PARSE_JSON($2)
FROM @my_stage/raw_events;
NULL instead of an error.SELECT COUNT(*) AS bad_rows
FROM events_raw
WHERE payload IS NULL;
Docs: TRY_PARSE_JSON.
Once JSON is in VARIANT:
SELECT
payload:customer.id::STRING AS customer_id,
payload:event_type::STRING AS event_type,
payload:properties.revenue::NUMERIC(10,2) AS revenue
FROM events_raw;
SELECT
payload['campaign name']::STRING AS campaign_name
FROM events_raw;
Snowflake JSON navigation: Semi-structured data.
Marketing and product events often store arrays: line_items, impressions, touchpoints.
payload:line_items is an array.LATERAL FLATTEN:SELECT
e.id,
li.value:sku::STRING AS sku,
li.value:price::NUMBER AS price
FROM events_raw e,
LATERAL FLATTEN(input => e.payload:line_items) li;
Docs: FLATTEN and LATERAL JOIN.
Snowflake treats empty strings and JSON null differently.
PARSE_JSON('') returns SQL NULL.PARSE_JSON('null') returns a JSON null inside VARIANT.d parameter:SELECT PARSE_JSON('{"a":1,"a":2}', 'd');
Snowflake keeps the last value.
If you run an agency or revenue team, you might not want your marketers writing SQL. You can still harness Snowflake’s JSON power via no-code tooling.
Modern ELT platforms (Fivetran, Airbyte, Stitch and others) automatically ingest JSON APIs and write PARSE_JSON under the hood.
Typical setup:
PARSE_JSON.FLATTEN to explode arrays.
Pros:
Cons:
Tools like dbt Cloud’s GUI or other visual modelers can sit on top of Snowflake and let non-engineers tweak JSON models.
Pattern:
payload:field and FLATTEN, then compiles to Snowflake.This lets a marketing ops manager extend models (add a new property from an ad platform payload) without hand-writing JSON navigation.
Business owners often want: “When new JSON events arrive, refresh my dashboards automatically.”
You can:
PARSE_JSON → aggregate KPIs → email a report.Snowflake tasks: TASK docs.
Manual SQL and no-code tools get you going, but they still rely on humans to maintain patterns. As your business adds more platforms and campaigns, JSON parsing becomes a repetitive, error-prone chore.
Simular’s AI computer agents are designed to automate exactly this kind of digital workflow: opening Snowflake worksheets, editing SQL, running queries, and integrating results with the rest of your stack.
Imagine you onboard a new ad network that delivers logs as JSON files.
An AI agent running on Simular Pro can:
TRY_PARSE_JSON to load raw events into VARIANT.LATERAL FLATTEN for key arrays (e.g., ad_groups, line_items).
Pros:
Cons:
Learn more about Simular’s agents: Simular Pro.
APIs and event schemas change quietly: a new field is added, data types shift, arrays become nested. Humans usually discover this only when dashboards break.
An AI agent can:
PARSE_JSON and FLATTEN still succeed (no type errors).This keeps your Snowflake environment aligned with real-world payloads without constant engineer attention.
For agencies and revenue teams, the ideal future state is simple: JSON in, dashboards out – with no one worrying about commas in SQL.
A Simular AI agent can orchestrate the full workflow across desktop, browser, and cloud:
PARSE_JSON/TRY_PARSE_JSON + FLATTEN models.
Pros:
Cons:
To see how these agents behave in real computer environments, explore the demos and docs at Simular Pro and learn about the research approach at Simular About.
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
Block quote
Ordered list
Unordered list
Bold text
Emphasis
Superscript
Subscript
For most teams, the cleanest path is to land JSON as-is and let Snowflake handle parsing.
A practical sequence:
CREATE TABLE raw_events (
src STRING,
load_ts TIMESTAMP,
json_str STRING
);
PARSE_JSON to convert the string into VARIANT:CREATE TABLE events_parsed AS
SELECT
src,
load_ts,
PARSE_JSON(json_str) AS payload
FROM raw_events;
payload into structured columns with dot/bracket notation and LATERAL FLATTEN.This two-step pattern (raw → parsed) keeps your pipeline resilient: you always have the original JSON if your parsing logic needs to change later.
To extract nested fields, you’ll use a combination of dot/bracket notation and casting.
payload looks like:{"customer":{"id":"123","address":{"city":"London"}}}
SELECT
payload:customer.id::STRING AS customer_id,
payload:customer.address.city::STRING AS city
FROM events_parsed;
SELECT
payload['customer']['address']['city']::STRING AS city
FROM events_parsed;
LATERAL FLATTEN:SELECT
li.value:item_id::STRING AS item_id
FROM events_parsed e,
LATERAL FLATTEN(input => e.payload:line_items) li;
This approach scales from simple lookups to deeply nested marketing or product event payloads.
Real-world JSON is often messy: missing commas, unexpected types, or partial payloads. Snowflake gives you tools to stay resilient.
INSERT INTO events_parsed
SELECT
src,
load_ts,
TRY_PARSE_JSON(json_str) AS payload
FROM raw_events;
Invalid JSON returns NULL instead of failing your whole load.CREATE TABLE events_bad AS
SELECT *
FROM raw_events r
LEFT JOIN events_parsed p
ON r.src = p.src AND r.load_ts = p.load_ts
WHERE p.payload IS NULL;
Now you can inspect and fix bad inputs without blocking the main pipeline.PARSE_JSON('null') yields a JSON null inside VARIANT, whereas an empty string or SQL NULL behaves differently. Design your downstream logic to distinguish these.payload to spot new or disappearing fields.This keeps your sales and marketing reporting running even when upstream APIs misbehave.
Flattening arrays is essential for things like line items, impressions, or multi-touch journeys.
payload:line_items.SELECT
e.id,
li.value:sku::STRING AS sku,
li.value:price::NUMBER AS price
FROM events_parsed e,
LATERAL FLATTEN(input => e.payload:line_items) li;
VALUE: the current element (most used).INDEX: the element’s index in the array.KEY, PATH, SEQ: useful for advanced debugging and recursion.FROM events_parsed e,
LATERAL FLATTEN(input => e.payload:orders) o,
LATERAL FLATTEN(input => o.value:items) i
Used well, FLATTEN turns complex event JSON into the fact tables your BI layer expects.
AI agents shine exactly where JSON parsing gets painful: repetitive SQL edits, UI clicks, and schema maintenance.
With a Simular-based AI computer agent, you can:
For sales and marketing teams, this moves you from “we’ll fix the JSON later” to a reliable, automated pipeline where Snowflake stays in sync with fast-changing campaign data, without constant engineer intervention.