Append a value. @param string A string value. @return this @throws JSONException If the value is out of sequence.
(String string)
| 99 | * @throws JSONException If the value is out of sequence. |
| 100 | */ |
| 101 | private JSONWriter append(String string) throws JSONException { |
| 102 | if (string == null) { |
| 103 | throw new JSONException("Null pointer"); |
| 104 | } |
| 105 | if (this.mode == 'o' || this.mode == 'a') { |
| 106 | try { |
| 107 | if (this.comma && this.mode == 'a') { |
| 108 | this.writer.write(','); |
| 109 | } |
| 110 | this.writer.write(string); |
| 111 | } catch (IOException e) { |
| 112 | throw new JSONException(e); |
| 113 | } |
| 114 | if (this.mode == 'o') { |
| 115 | this.mode = 'k'; |
| 116 | } |
| 117 | this.comma = true; |
| 118 | return this; |
| 119 | } |
| 120 | throw new JSONException("Value out of sequence."); |
| 121 | } |
| 122 | |
| 123 | /** |
| 124 | * Begin appending a new array. All values until the balancing |