I know the title is quite cliched, but it is not about storing JSON data in SQL Server.
I have a JSONArray
with JSONObjects with keys that match the column names in SQL Server 2012. I want to save the data to the database into the proper columns.
I know the obvious way to do this is the iterate through the JSONArray
and save the values with individual insert commands. I was wondering if there was another way to do this.
I don't want to use T-SQL. I want to handle this from Java only.
Here is an example data that matches the format of my JSONArray
:
[
{
"FEATURE":"A",
"OPTION":"92384",
"ERROR_TYPE":"MISSING",
"DESCRIPTION":"Feature A is missing the option 92384",
"SERIAL_NUMBER":"249752-23894"
},
{
"FEATURE":"B",
"OPTION":"0288394",
"ERROR_TYPE":"MISSING",
"DESCRIPTION":"Feature B is missing the option 0288394",
"SERIAL_NUMBER":"Y2394-20392Q"
}
]
My SQLServer table looks like this:
What would be best way to achieve this without looping through each JSONArray
?