
During this post we will discuss about how to handle JSON via javascript functions. Though there are many Javascript functions which we can leverage in our Snowflake stored procedure. But for this post we will discuss about two key JS functions to handle JSON data. Also Please note I am not well versed with javascript programming but thanks to other blogs who helped me to implement the below procedure. We will be discussing JSON.parse () and JSON.stringify() functions to process the JSON data.
JSON.parse () :Parse the data with JSON.parse(), and the data becomes a JavaScript object
JSON.stringify(): static method converts a JavaScript value to a JSON string.
Lets try to understand these functions with practical examples.
- When we fetch the JSON value without any parsing. Observe the output of the v_jsonval.

- Now comment the first part and enable the JSON.PARSE and observe the output.

- Now Try to insert the Javascript object value without any conversion.

- Use the JSON.stringify() method converts a JavaScript value to a JSON string.

A table gets created with JSON values.

In the end, someone can ask why we need these JSON.parse () and JSON.stringify() and we can achieve this with simple approach like this:

But I wanted to highlight above functions w.r.t to Snowflake Scripting procedure. We can follow above procedure as well.