Hi I need help below is the json where I have to read and create csv file as output.
{
"COMP_DUR": "100",
"DATE": "2024-01-10T16:38:00Z",
"EMAIL": "[email protected]",
"ID": "1111",
"approval": "Medium",
"criteria": "Medium",
"access": "Neutral"
}
highlighted in yellow colour are json key and values but in green colour are the dynamic json values which i have to map with json key(REQ and RES)
I am doing this as follows
JObject convertedJson = JObject.Parse(json);
IDictionary<string, string> quesRespkeyValueParam = new Dictionary<string, string>();
foreach (var item in convertedJson.Properties())
{
//Console.WriteLine(item.Name + "," + item.Value);
if (item.Name == "SURVEY_ID" || item.Name == "RESPONDENT_ID" || item.Name == "RESPONDENT_NAME" || item.Name == "RESPONDENT_EMAIL" ||
item.Name == "DATE_RESPONDED" || item.Name == "COMPLETION_DURATION" || item.Name == "SURVEY_URL")
{
JsonSerializerOptions options = new()
{
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingDefault
};
}
else
{
quesRespkeyValueParam.Add(item.Name, (string)item.Value);
tempObj.QuesResp = (Dictionary<string, string>)quesRespkeyValueParam;
}
}
obj = tempObj;
I am able to add values in IDictionary object but not able to map with json keys REQ and RES
please help. Thanks