0
Answer

How to split Complex JSON Data retrieving from MongoDB

Revathi Parvathi

Revathi Parvathi

7y
199
1
I want to insert FoodDetails Array of every volunteer into MS SQL,
how can I split this Json to two arrays i.e 1.Identification Details and 2.Food Details
 
{
"formdata": [
{
"_id": "59bfa63b2b43841d8c029c9f",
"data": {
"formList": [
{
"IdentificationDetails": [
{
"Visit_No": "1",
"Interviewer_Name": "Priya",
"Interview_Date": "2017-09-18T10:55:11.238Z",
"Study_Id": "1",
"Volunteer_Id": "MDRF001",
"Form_Name": "Food Frequency Questionnarie",
"Status": "Data Entry Completed",
"Study_Name": "INDIAB study",
"Volunteer_Name": "Kavya",
"Volunteer_Site": 1,
"Created_Emp_Id": "1",
"Form_Id": null
}
]
},
{
"FoodDetails": [
{
"Volunteer_Id": "MDRF001",
"Meal_Session_Id": 120,
"Food_Id": 544,
"Portion_Tool": 23,
"Portion_Size": 15,
"Serving_Size": "2",
"Frequency_Serving": "Daily",
"Value": "2"
},
{
"Volunteer_Id": "MDRF001",
"Meal_Session_Id": 121,
"Food_Id": 543,
"Portion_Tool": 18,
"Portion_Size": 13,
"Serving_Size": "3",
"Frequency_Serving": "Monthly",
"Value": "1"
}
]
}
]
}
},
{
"_id": "5943545bfa63b2b43841d8c029c9f",
"data": {
"formList": [
{
"IdentificationDetails": [
{
"Visit_No": "1",
"Interviewer_Name": "Annes",
"Interview_Date": "2017-09-18T10:55:11.238Z",
"Study_Id": "1",
"Volunteer_Id": "MDRF002",
"Form_Name": "Food Frequency Questionnarie",
"Status": "Data Entry Completed",
"Study_Name": "INDIAB study",
"Volunteer_Name": "KAVITHA",
"Volunteer_Site": 1,
"Created_Emp_Id": "1",
"Form_Id": null
}
]
},
{
"FoodDetails": [
{
"Volunteer_Id": "MDRF002",
"Meal_Session_Id": 120,
"Food_Id": 544,
"Portion_Tool": 23,
"Portion_Size": 15,
"Serving_Size": "2",
"Frequency_Serving": "Daily",
"Value": "2"
},
{
"Volunteer_Id": "MDRF002",
"Meal_Session_Id": 121,
"Food_Id": 543,
"Portion_Tool": 18,
"Portion_Size": 13,
"Serving_Size": "3",
"Frequency_Serving": "Monthly",
"Value": "1"
}
]
}
]
}
}
]
}