Package dev.frostlake.functions.scalar
Class JsonTypeHelper
java.lang.Object
dev.frostlake.functions.scalar.JsonTypeHelper
Shared utilities for JSON variant type-checking functions.
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringDROP every backslash that does not begin a valid JSON escape (i.e. is not followed by one of the characters" \ / b f n r t u) — live-verified: Snowflake's PARSE_JSON turns"a\d+"intoad+, discarding the invalid backslash rather than keeping it.static tools.jackson.databind.JsonNodestatic tools.jackson.databind.JsonNodeparseLenient(String input) Parse JSON the way Snowflake tolerates it: strictly first, and on failure retry after relaxing the things a strict parser rejects but Snowflake accepts — an over-escaped quote (\', whose backslash is dropped), invalid backslash escapes (e.g. a regex\d, whose backslash is kept literally), and finally a trailing comma or a raw control character inside a string.static StringquotedJsonStringText(Object value) The unquoted text of a value that is a QUOTED JSON string ("...") — the form path extraction uses for string values whose content looks like JSON structure — or null when the value is anything else.
-
Method Details
-
parse
-
parseLenient
Parse JSON the way Snowflake tolerates it: strictly first, and on failure retry after relaxing the things a strict parser rejects but Snowflake accepts — an over-escaped quote (\', whose backslash is dropped), invalid backslash escapes (e.g. a regex\d, whose backslash is kept literally), and finally a trailing comma or a raw control character inside a string. Returns null if it still cannot be parsed. -
quotedJsonStringText
The unquoted text of a value that is a QUOTED JSON string ("...") — the form path extraction uses for string values whose content looks like JSON structure — or null when the value is anything else. PARSE_JSON/TRY_PARSE_JSON and the VARCHAR cast use this so a variant string field holding JSON text round-trips to its raw text before parsing. -
escapeInvalidBackslashes
DROP every backslash that does not begin a valid JSON escape (i.e. is not followed by one of the characters" \ / b f n r t u) — live-verified: Snowflake's PARSE_JSON turns"a\d+"intoad+, discarding the invalid backslash rather than keeping it. Valid escapes and already-escaped backslashes are left untouched.
-