* If the key is out of place. For example, keys do not belong in
* arrays or if the key is null.
*/
public JsonWriter key(String s) {
if (s == null) {
throw new JsonException("Null key.");
}
if (this.mode == 'k') {
try {
stack[top - 1].putOnce(s, Boolean.TRUE);
if (this.comma) {
this.writer.write(',');
}
this.writer.write(JsonObject.quote(s));
this.writer.write(':');
this.comma = false;
this.mode = 'o';
return this;
} catch (IOException e) {
throw new JsonException(e);
}
}
throw new JsonException("Misplaced key.");
}