Skip to content
Advertisement

Nested JSON parsing using Snowflake SQL

I have a problem parsing a certain nested JSON structure in Snowflake. The problem here is the usage of special characters like @ and # for example for some of the elements. Those characters prevents me from using simple dot notation when trying to access some of the elements without resourcing to a really complicated queries utilizing joins and where clauses on the flattened parts of the structure. Here’s an example of how the JSON file looks like:

Is it possible to get those elements starting with @ and # like using some escape characters or something similar in SQL code?

Advertisement

Answer

Use quotes around the attributes with special characters. For example:

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement