I have the requirement as follows. The Json needs to look like this:
"facilityId": "{{facilityId}}",
"apiDate": {{apiDate}},
"apiSignature": "{{apiSignature}}",
"surveys": [
{
"sessionId": "sesh1",
"instrumentId": "DEMO",
"clientId": "a100",
"assignedToType": "Client",
"completeDate": "2/3/19",
"answerStyle": "byValue",
"Q1": "This is a long test text message of the testering.",
"Q2": "2",
"Q3": "2|3|1",
"Q4": 9
},
{
"sessionId": "sesh2",
"instrumentId": "DEMO",
"clientId": "a101",
"assignedToType": "Client",
"completeDate": "20201007",
"answerStyle": "byText",
"Q1": "Green",
"Q2": "Sometimes",
"Q3": "Agree",
"Q4": 9
}
]
}
I need the Q1,Q2,Q3....ect.... to be a dictionary since its a dynamic amount of questions.
But anytime I use a dictionary, I get the following from it....
"surveyAnswers":
{
"Q1": "Green",
"Q2": "Sometimes",
"Q3": "Agree",
"Q4": 9
}
I need it to flatten and remove "surveyAnswers"
I have tried all of the flattening techniques on here but that changes it to this
"surveyAnswers.Q1": "Green",
"surveyAnswers.Q2": "Sometimes",
"surveyAnswers.Q3": "Agree",
"surveyAnswers.Q4": 9
}
How can I just flatten the dictionary to not include the name of the dictionary and just appear to be another property of my object.
I hope that makes sense.
Thanks