Package org.json

Examples of org.json.JSONException


            if (probe) {
                log();
            }
            String name = read(this.namehuff, this.namehuffext, this.namekeep);
            if (jsonobject.opt(name) != null) {
                throw new JSONException("Duplicate key.");
            }
            jsonobject.put(name, !bit()
                    ? read(this.stringhuff, this.stringhuffext, this.stringkeep)
                    : readValue());
            if (!bit()) {
View Full Code Here


            Object value;
            try {
                value = JSONObject.stringToValue(new String(bytes, 0, length,
                        "US-ASCII"));
            } catch (java.io.UnsupportedEncodingException e) {
                throw new JSONException(e);
            }
            this.valuekeep.register(value);
            return value;
        case 2:
            return getAndTick(this.valuekeep, this.bitreader);
        case 3:
            return readJSON();
        default:
            throw new JSONException("Impossible.");
        }
    }
View Full Code Here

        break;
      token.back();
      Object key = token.nextValue();
      char t = token.nextClean();
      if (t != ':')
        throw new JSONException("Parse JSON object error");
      addObjectElement((String)key, token, nestedHTable,
          nestedRow);
      if (maxNumLines > 0 && numObjects >= maxNumLines)
        break;
      c = token.nextClean();
      if (c != ',' && c != '}')
        throw new JSONException("Parse JSON object error");
      if (c == ',') {
        c = token.nextClean();
      }
    }
  }
View Full Code Here

      }
      if (maxNumLines > 0 && numObjects >= maxNumLines)
        break;
      c = token.nextClean();
      if (c != ',' && c != ']')
        throw new JSONException("Parse JSON array error");
      if (c == ',') {
        c = token.nextClean();
      }
    }
View Full Code Here

        JSONTokener t = new JSONTokener(s);
        Object o = t.nextValue();
        if (o instanceof JSONObject) {
            return (JSONObject) o;
        } else {
            throw new JSONException(s + " couldn't be parsed as JSON object");
        }
  }
View Full Code Here

    private void insertReference( int insert, Object item )
        throws JSONException
    {
        if( insert < 0 || insert > references.length() )
        {
            throw new JSONException( "JSONArray[" + insert + "] is out of bounds." );
        }
        if( insert == references.length() )
        {
            // append
            references.put( item );
View Full Code Here

  public JSONObject putOnce(String key, Object value) throws JSONException {
    Object storedValue;
    if (key != null && value != null) {
      if ((storedValue = this.opt(key)) != null) {
        if (!storedValue.equals(value)) // Throw if values are different
          throw new JSONException("Duplicate key \"" + key + "\"");
        else
          return this;
      }
      this.put(key, value);
    }
View Full Code Here

            }
          }
        });
      }
      catch (IOException e) {
        throw new JSONException(e);
      }
    }
  }
View Full Code Here

        dateStr = dateStr.substring(0, dateStr.length() - 1)
            + "GMT-00:00";
      } else {
        final int inset = 6;
        if (dateStr.length() <= inset)
          throw new JSONException("Bad date value " + dateStr);
        String s0 = dateStr.substring(0, dateStr.length() - inset);
        String s1 = dateStr.substring(dateStr.length() - inset,
            dateStr.length());
        dateStr = s0 + "GMT" + s1;
      }
      return RedmineDateUtils.FULL_DATE_FORMAT_V2.get().parse(dateStr);
    } catch (ParseException e) {
      throw new JSONException("Bad date value " + dateStr);
    }
  }
View Full Code Here

            dateFormat = RedmineDateUtils.SHORT_DATE_FORMAT_V2.get();

        try {
            return dateFormat.parse(dateStr);
        } catch (ParseException e) {
            throw new JSONException("Bad date " + dateStr);
        }
  }
View Full Code Here

TOP

Related Classes of org.json.JSONException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.