Java_list<string> string[] Stitching JSON

Source: Internet
Author: User

  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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.