Link to home
Start Free TrialLog in
Avatar of kevinvw1
kevinvw1

asked on

trying to import JSON into Microsoft SQL database using C#

Hi, I am pulling lead data in  JSON format  from a web site.
This page has an exmple of the JSON Response - http://docs.hubapi.com/wiki/Searching_Leads 
It is an array of one or more leads.  Each lead has several basic fields.
Each lead can also contain child info and some of that child info can also have child info.

I am fairly new to C# and .NET.  I have successfully been able to use JSON.NET to loop through the JSON and then loop through each lead and I can reference the different data fields and print the values to the immediate window.

My question - what would be the most efficient way to get the data into a MS SQL database?
I know I could create my sql tables in advance and then loop through the JSON leads and grab each value and populate the main data rows and the child table rows.
BUT is there a more efficient more automatic way of doing this?
AND what if the JSON format changes (they add a new field in the middle somewhere)?

Thanks in advance!
ASKER CERTIFIED SOLUTION
Avatar of leakim971
leakim971
Flag of Guadeloupe image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Another way : You may create a dedicated sql stored procedure accepting a json string and doing the job. So if the format change you "just" need to update the stored procedure
Thanks for the points!