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!
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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!
An empty blog :(
http://hodentek.blogspot.com/2007/01/native-support-in-databases-for-json.html
post from :
http://social.msdn.microsoft.com/Forums/en/vssmartdevicesvbcs/thread/44b733a3-669e-4b83-a835-df5c33e60582