Gets the String value associated with the specified key. @webref jsonobject:method @webBrief Gets the String value associated with the specified key @param key a key string @return A string which is the value. @throws RuntimeException if there is no string value for the key. @see JSON
(String key)
| 579 | * @see JSONObject#getBoolean(String) |
| 580 | */ |
| 581 | public String getString(String key) { |
| 582 | Object object = this.get(key); |
| 583 | if (object == null) { |
| 584 | // Adding for rev 0257 in line with other p5 api |
| 585 | return null; |
| 586 | } |
| 587 | if (object instanceof String) { |
| 588 | return (String)object; |
| 589 | } |
| 590 | throw new RuntimeException("JSONObject[" + quote(key) + "] is not a string"); |
| 591 | } |
| 592 | |
| 593 | |
| 594 | /** |