问题
I have a JSON source that has a weird layout where there are unknown amount of columns.
https://theunitedstates.io/congress-legislators/committee-membership-current.json
The format is like the following:
ColumnHeaders => HLAG HSAG HSAG01 .... to unknown
Single row of Data JSON JSON JSON
How can I get the data like this:
Col1 Col2
HLAG JSON
HSAG JSON
HSAG01 JSON
I am currently working in SSIS so I have C# solutions available to me.
I just don't know how to deal with unknown columns in SSIS.
Thanks for your help.
回答1:
In case you cannot find a more convenient solution, here's how it could be done using the command-line tool, jq:
jq -jrc 'keys_unsorted[] as $key | $key,"\t",.[$key],"\n" ' committee-membership-current.json
This produces one line per "column-header" in accordance with the problem description, using a literal tab ("\t") as separator. A different separator can be specified in the obvious manner.
回答2:
There are many articles online describing the process of parsing complex Json, the main idea is to use a script component with System.Web.Extensions
assembly. I think that the following article is what you are looking for:
- Importing Complex JSON files using SQL Server Integration Services
Other helpful articles:
- Approaches to Import JSON in SSIS (SQL Server 2016+) Part 1
- Importing JSON Files Using SQL Server Integration Services
来源:https://stackoverflow.com/questions/56534451/how-process-json-data-that-needs-to-be-unpivoted