i have json like
{
"condition": "AND",
"rules": [{
"id": "BirthDate",
"field": "BirthDate",
"type": "date",
"input": "text",
"operator": "equal",
"value": "2016/04/13"
}]}
i just want to iterate it on servlet for that i create
public String getRuleList(){
String ruleList=this.get("rules");
return ruleList;
}
public String getcondition(){
return this.get("condition");
}
as getter setter when i send this json without using JSON.stringify i got the value of condition but unable to fetch rules.By using JSON.stringify i unable to fetch anything. please help..
rules
is JSONArray and simple get returns an object. Try to get it with the json libraries custom method. If you are using org.json
try this
this.getJSONArray('rules')
Try to provide some more information such as the json library you are using, the output you got for this.get('rules')
and how is this
initialized for a much better answer
To solve above problem i do
result =JSON.stringify(result); var json = JSON.parse(result); var queryData={ rules:JSON.stringify(json.rules), condition:JSON.stringify(json.condition) }; console.log("result"+JSON.stringify(result)); if (!$.isEmptyObject(result)) { var url = location.protocol + "//" + location.host +appContext+"?command=QueryBuilderServlet&action=getQueryJson"; $.ajax({ url:url, type: "POST",
thanks a lot for your help
data:queryData, dataType:'json', });
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.