java - JSON validation is not happening -
i facing problem in json validation. code using
import net.sf.json.jsonexception; import net.sf.json.jsonobject; string stringtovalidate="{'customer':[{'condition':'matches','value':'nordstrom,nordstromrack,neimanmarcus,neimanmarcuslastcall,tjmaxx,macys,dsw,saksfifthavenue,off5th,bananarepublic,jcrew,bloomingdales'}],'notcustomer':[{'condition':'matches','value':'neimanmarcuslastcall'}],'daterange':[{'condition':'in last','value':'6 months'}]}"; try { system.out.println(stringtovalidate); jsonobject.fromobject(stringtovalidate); /* try { map<string, object> tsmap = new json2java().getmap(stringtovalidate); } catch (exception e) { // todo auto-generated catch block e.printstacktrace(); return false; }*/ system.out.println(true); } catch (jsonexception je) { je.printstacktrace(); system.out.println(false); }
and validating syntax fine. can see using single commas ('
) tag names 'customer':.....
. problem is, if remove '
tag still it's printing true , want fail condition in case.
Comments
Post a Comment