I have a 2 GB text file in JSON format that I wish to parse using C# in Visual Studio 2013. How can I parse this data and insert it into a Microsoft Azure SQL database?
-
http://stackoverflow.com/questions/3275863/does-net-4-have-a-built-in-json-serializer-deserializer – beachwood23 Nov 25 '13 at 17:59
-
possible duplicate of [Parse JSON in C#](http://stackoverflow.com/questions/1212344/parse-json-in-c-sharp) – Austin Salonen Nov 25 '13 at 18:00
-
Side note: 2GB of JSON (or any other format that requires matching closing tags like XML) sounds like a bad idea... Unless you can chunk the result before it reaches your code to significantly decrease size of each chunk you likely need to write your own reader (reading JSON requires small amount of code - so should not be a problem even if you can't find existing one). – Alexei Levenkov Nov 25 '13 at 18:13
2 Answers
You may try to check DataContractJsonSerializer Class
Remarks
Use the DataContractJsonSerializer class to serialize instances of a type into a JSON document and to deserialize a JSON document into an instance of a type. For example, you can create a type named Person with properties that contain essential data, such as a name and address. You can then create and manipulate an instance of the Person class and write all of its property values in a JSON document for later retrieval. This JSON document can later be deserialized into the Person class or another class with an equivalent data contract.
If an error occurs during the serialization of an outgoing reply on the server or the reply operation throws an exception for some other reason, it may not get returned to the client as a fault.
Also check How to: Serialize and Deserialize JSON Data

- 168,305
- 31
- 280
- 331
Azure SQL Database supports OPENJSON function that can parse JSON and transform it into table see https://azure.microsoft.com/en-us/updates/public-preview-json-in-azure-sql-database/ Since you have big JSON you might compress it on .Net side and decompress it in Azure SQL Db using DECOMPRESS function to reduce network bandwidth.

- 13,232
- 4
- 40
- 55