Home > Blockchain >  Reading JSON in Azure Synapse
Reading JSON in Azure Synapse

Time:09-22

I'm trying to understand the code for reading JSON file in Synapse Analytics. And here's the code provided by Microsoft documentation: enter image description here

I wonder why the format = 'csv'. Is it trying to convert json to csv to flatten the hierarchy?

(1) JSON is not a data type in SQL Server. There is no data type name JSON. What we have in SQL Server are tools like functions which work on text and provide support for strings which are JSON's like format. Therefore, we do not CONVERT to JSON or from JSON.

(2) The format parameter has nothing to do with JSON. It specifies that the content of the file is a comma separated values file. You can (and should) use it whenever your file is well formatted as comma separated values file (also commonly known as csv file).

In this specific sample in the document, the values in the csv file are strings, which each one of them has a valid JSON format. Only after you read the file using the openrowset, we start to parse the content of the text as JSON.

Notice that only after the title "Parse JSON documents" in the document, the document starts to speak about parsing the text as JSON.

  • Related