PrivateString Getjsonstr (list<string>jsonkeylist, string[] values) {String Jsonstr= "{"; if(Jsonkeylist = =NULL) {log.getinstance (). Printerror ( This. GetClass (). GetName (), "Spelling JSON error, JSON object property name list is empty"); return NULL; } if(Values = =NULL) {log.getinstance (). Printerror ( This. GetClass (). GetName (), "Spelling JSON error, JSON object property value array is empty"); return NULL; } if(Jsonkeylist.size ()! =values.length) {log.getinstance (). Printerror ( This. GetClass (). GetName (), "Spelling JSON error, JSON object property name and number of values does not correspond"); return NULL; } if(Values.length < 2) {log.getinstance (). Printerror ( This. GetClass (). GetName (), "error in spelling JSON, number of JSON object property values less than 2"); return NULL; } if(Jsonkeylist.size () <= 0) {Jsonstr+ = "\" groupid\ ": \" -1\ ""; } for(inti = 0; I < jsonkeylist.size (); i++){ //JSON property name is empty if(!Stringutils.isempty (Jsonkeylist.get (i))) {log.getinstance (). Printerror ( This. GetClass (). GetName (), "Spelling JSON error, JSON object property name is empty"); return NULL; } if(!Stringutils.isempty (Values[i])) { //If this is the last item if(i = = Values.length-1){ //If the previous item is-1, it's normal . if("-1". Equals (Values[values.length-2]) {values[values.length-1] = "Sync Contacts Group"; }Else{ return NULL; } }Else{log.getinstance (). Printerror ( This. GetClass (). GetName (), "error in spelling JSON, null JSON object property value"); return NULL; }} jsonstr+ = "\" + jsonkeylist.get (i) + "\": \ "" + values[i] + "\" "; if(I < Jsonkeylist.size ()-1) {Jsonstr+= ","; }} jsonstr+= "}"; Log.getinstance (). Printinfo ( This. GetClass (). GetName (), JSONSTR); returnJsonstr; }
Java_list<string> string[] Stitching JSON