我将此作为Json字符串发送到Web api问题:如何迭代并获取每个数组,对象数组和对象的值?
generateQMEPanelRequest(date: Array<any>, text: Array<string>, checkboxes: Array<number>, personserved: IPersonServed[], qme31_7: IQme31_7): ng.IPromise<any> {
var data = {
Date: date,
Text: text,
CheckBox: checkboxes,
PersonServed: personserved,
QQME_31_7: qme31_7
};
return this.$http.post('/api/ClientForms/QMEPanelRequest',data).then(this.handleSuccess, this.handleError);
在Web api上我将模型作为Jobject:
Model {{
"Date": [
"2017-04-03T07:00:00Z",
"2017-04-10T07:00:00Z",
"2017-06-13T07:00:00Z"
],
"Text": [
"mam",
"5445",
"MDE Dermatology"
],
"CheckBox": [
"1",
"4"
],
"PersonServed": [
{
"personId": 1,
"method": "B",
"name": "dd",
"address": "d",
"city": "d",
"state": "d",
"zipCode": "d",
"$$hashKey": "object:674"
}
],
"QQME_31_7": {
"recordsOfFirstName": "a",
"recordsOfMI": "a",
"recordsOfLastName": "dd",
"caseNo": "d",
"ownerAddress": "ddd",
"ownerState": "dd",
"ownerZip": "d"
}
}}
public IHttpActionResult QMEPanelRequest(JObject data)
{
如何迭代并获取每个Array,Object Array和Object的值?
答案 0 :(得分:0)
我做了这个
JArray Date = (JArray)data["Date"];
JArray Text = (JArray)data["Text"];
JArray CheckBox = (JArray)data["CheckBox"];
JArray PersonServed = (JArray)data["PersonServed"];