I’m trying create this:
var a = {
"requestM" : {
"task" : "list",
"listRequest" : {
"checkedEntryType" : "GLOBAL",
"targetList" : {
"maxResult" : "2",
"status" : "OPEN",
"entryType" : "CALL"
},
"targetList" : {
"maxResult" : "3",
"status" : "CLOSED",
"entryType" : "CALL"
},
"targetList" : {
"maxResult" : "2",
"status" : "OPEN",
"entryType" : "TODO"
},
"targetList" : {
"maxResult" : "2",
"status" : "CLOSED",
"entryType" : "TODO"
}
}
}
}
The targetList is not nested inside an array, but it repeats. Now I try to create the message like this:
var reqJson = {
"requestM" : {
"task" : "list",
"listRequest" : {
"checkedEntryType" : checkedEntryType
}
}
};
reqJson.requestM.listRequest.targetList={
"maxResult" : 10,
"status" : "OPEN",
"entryType" : "CALL"
};
reqJson.requestM.listRequest.targetList={
"maxResult" : 10,
"status" : "OPEN",
"entryType" : "TODO"
};
However the second targetList will replace the first one. How to avoid this? Thanks!
I think this is not possible as in json object
p1 and p2 are considered to be properties of the object, so duplicate properties are overwritten. Instead try to use array
i.e