asked on
SSIS JSON Question
I have a SSIS package that connects to a REST API using a script component and retrieves json data about some projects. I can write this data to a file and it seems fine. Now I want to send it to SQL Server instead of a file.
Here is the format for the json.
"is_valid":true,
"message":"Data Found. Good job.",
"data":[
{
"name":"CP Project",
"p_id":566567416,
"due_date":"2020-07-18",
"project_name":"Some Name",
"project_id":"13096"
},
{
"name":"RST Project",
"p_id":560878633,
"due_date":"2020-07-31",
"project_name":"another name",
"project_id":"12002"
},
{
"name":"AO Project",
"p_id":527765988,
"due_date":"2020-04-27",
"project_name":"AO",
"project_id":"1206773"
},
There are just over 4000 entries.
Following an example I found, I changed the json to xml.
// Toss the JSON response in to XML so we can work with it better
XmlDocument xd = new XmlDocument();
XmlDictionaryReader xr = JsonReaderWriterFactory.CreateJsonReader(resp.GetResponseStream(),
XmlDictionaryReaderQuotas.Max);
xr.Read();
xd.LoadXml(xr.ReadOuterXml());
Then I send it to the data buffer.
// Put each item returned in to a new Buffer row
items = xd.DocumentElement.SelectNodes("/root/data/item");
foreach (XmlNode item in items)
I think this is where my issue is. I am not sure what should be in the SelectNodes value. The "/root/data/item" is from the example and I am thinking it is not valid for my file and that is why every field in every column of my output is NULL.
How do I know what to put there based on the json above?
I am googling this but so far I have not found anything I understand. Thank you!
Jim