Solved

trying to import JSON into Microsoft SQL database using C#

Posted on 2010-09-23
4
1,396 Views
Last Modified: 2013-11-08
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!
0
Comment
Question by:kevinvw1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
4 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 33750806
>BUT is there a more efficient more automatic way of doing this?
I don't know anyone, perhaps the next version of SQL Server...

>AND what if the JSON format changes (they add a new field in the middle somewhere)?
This is a common problem with all type of data format (xml, csv and so on) not only with JSON
If you need the new data, you create a new row for it and modify your DataContract (for example)
0
 
LVL 82

Expert Comment

by:leakim971
ID: 33750830
0
 
LVL 82

Expert Comment

by:leakim971
ID: 33762984
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
0
 
LVL 82

Expert Comment

by:leakim971
ID: 33872387
Thanks for the points!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

710 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question