コード例 #1
0
 /**
  * Construct a JSONArray from a JSONTokener.
  *
  * @param x A JSONTokener
  * @throws JSONException If there is a syntax error.
  */
 public JSONArray(JSONTokener x) throws JSONException {
   this();
   if (x.nextClean() != '[') {
     throw x.syntaxError("A JSONArray text must start with '['");
   }
   if (x.nextClean() != ']') {
     x.back();
     for (; ; ) {
       if (x.nextClean() == ',') {
         x.back();
         this.myArrayList.add(JSONObject.NULL);
       } else {
         x.back();
         this.myArrayList.add(x.nextValue());
       }
       switch (x.nextClean()) {
         case ';':
         case ',':
           if (x.nextClean() == ']') {
             return;
           }
           x.back();
           break;
         case ']':
           return;
         default:
           throw x.syntaxError("Expected a ',' or ']'");
       }
     }
   }
 }
コード例 #2
0
ファイル: JSONArray.java プロジェクト: Bingle-labake/Vine15
 public JSONArray(JSONTokener paramJSONTokener) throws JSONException {
   this();
   if (paramJSONTokener.nextClean() != '[')
     throw paramJSONTokener.syntaxError("A JSONArray text must start with '['");
   if (paramJSONTokener.nextClean() != ']') paramJSONTokener.back();
   while (true) {
     if (paramJSONTokener.nextClean() == ',') {
       paramJSONTokener.back();
       this.myArrayList.add(JSONObject.NULL);
     }
     while (true)
       switch (paramJSONTokener.nextClean()) {
         default:
           throw paramJSONTokener.syntaxError("Expected a ',' or ']'");
           paramJSONTokener.back();
           this.myArrayList.add(paramJSONTokener.nextValue());
         case ',':
         case ';':
         case ']':
       }
     if (paramJSONTokener.nextClean() == ']') return;
     paramJSONTokener.back();
   }
 }