Once again I have edited the code and question
This code is the logic to receive response data through the full request message.
I am making an api server
I want to extract only the data I want from the response data and put it back in the list
this is the code i made
public List<api_model> getList(Dictionary<string, object> param)
{
List<api_model> tempList = new List<api_model>();
List<api_model> resultList = new List<api_model>();
JsonRes.GetListRes res;
try
{
GetListRequest jsonReq = new GetListRequest();
jsonReq.Session = param;
string strJsonReq = jsonReq.TransformText();
string strUri = String.Format("'API ADRESS'");
string strJsonRes = httpUtils.HttpRequest(strUri, "POST", strJsonReq).ToString();
using (JsonTextReader reader = new JsonTextReader(new System.IO.StringReader(strJsonRes)))
{
JsonSerializer serializer = new JsonSerializer();
res = (JsonRes.GetListRes)serializer.Deserialize(reader, typeof(JsonRes.GetListRes));
}
if (res.outputCode.Equals("1"))
{
foreach (JsonRes.GetListRes.Data data in res.dataList)
{
List<api_model.array> arrayList = new List<api_model.array>();
foreach (JsonRes.GetListRes.array ar in data.arrayList)
{
api_model.array arrays = api_model api_model.array
{
foodCode = ar.foodCode,
foodCount = ar.foodCount
};
arrayList.Add(arrays);
}
api_model um = new api_model
{
foodID = data.foodID,
food = arrayList
};
tempList.Add(bm);
}
resultList = tempList;
}
}
catch (Exception ex)
{
CommonUtils.errorLog(ex.ToString());
throw ex;
}
return resultList ;
}
I want to compare the full request and response data with linq and put only the desired data in the list again
full text of request
{
"Type": "restaurant",
"food": [
{
"foodID": "chicken",
"foodCODE": "001",
"foodVALUE": "1"
},
{
"foodID": "lamb",
"foodCODE": "002",
"foodVALUE": "1"
},
{
"foodID": "pork",
"foodCODE": "003",
"foodVALUE": "1"
},
{
"foodID": "eggs",
"foodCODE": "004",
"foodVALUE": "1"
}
]
}
response data
{
"Code": "00",
"Msg": "SUCCESS",
"Data": [
{
"foodID": "123456",
"food": [
{
"foodCode": "001",
"foodCount": "1"
},
{
"foodCode": "002",
"foodCount": "1"
},
{
"foodCode": "003",
"foodCount": "1"
},
{
"foodCode": "004",
"foodCount": "1"
},
{
"foodCode": "005",
"foodCount": "1"
}
]
},
{
"foodID": "56789",
"food": [
{
"foodCode": "001",
"foodCount": "1"
},
{request
"foodCode": "002",
"foodCount": "1"
},
{
"foodCode": "003",
"foodCount": "1"
},
{
"foodCode": "004",
"foodCount": "0"
},
{
"foodCode": "005",
"foodCount": "1"
}
]
}
]
}
I want to extract only the same data by comparing foodVALUE data in the full request and foodCount to response data
"foodID": "123456",
"food": [
{
"foodCode": "001",
"foodCount": "1"
},
{
"foodCode": "002",
"foodCount": "1"
},
{
"foodCode": "003",
"foodCount": "1"
},
{
"foodCode": "004",
"foodCount": "1"
},
{
"foodCode": "005",
"foodCount": "1"
}
]
I want to extract only this data and put it in resultList