Get the next value. The value can be a Boolean, Double, Integer, JSONArray, JSONObject, Long, or String, or the JSONObject.NULL object. @throws JSONException If syntax error. @return An object.
()
| 350 | * @return An object. |
| 351 | */ |
| 352 | public Object nextValue() { |
| 353 | char c = this.nextClean(); |
| 354 | String string; |
| 355 | |
| 356 | switch (c) { |
| 357 | case '"': |
| 358 | case '\'': |
| 359 | return this.nextString(c); |
| 360 | case '{': |
| 361 | this.back(); |
| 362 | return new JSONObject(this); |
| 363 | case '[': |
| 364 | this.back(); |
| 365 | return new JSONArray(this); |
| 366 | } |
| 367 | |
| 368 | /* |
| 369 | * Handle unquoted text. This could be the values true, false, or |
| 370 | * null, or it can be a number. An implementation (such as this one) |
| 371 | * is allowed to also accept non-standard forms. |
| 372 | * |
| 373 | * Accumulate characters until we reach the end of the text or a |
| 374 | * formatting character. |
| 375 | */ |
| 376 | |
| 377 | StringBuilder sb = new StringBuilder(); |
| 378 | while (c >= ' ' && ",:]}/\\\"[{;=#".indexOf(c) < 0) { |
| 379 | sb.append(c); |
| 380 | c = this.next(); |
| 381 | } |
| 382 | this.back(); |
| 383 | |
| 384 | string = sb.toString().trim(); |
| 385 | if ("".equals(string)) { |
| 386 | throw new RuntimeException("Missing value"); |
| 387 | } |
| 388 | return JSONObject.stringToValue(string); |
| 389 | } |
| 390 | |
| 391 | |
| 392 | /** |
no test coverage detected