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