@Test public void failsWhenEndObjectIsBeforeStartObject() throws Exception { thrown.expect(JsonException.class); jsonWriter.writeEndObject(); }
public void writeEndObject() throws JsonException { try { JsonToken token = stack.pop(); if (token == object) { writer.write('}'); commaFirst = true; } else { throw new JsonException("Syntax error. Unexpected element '}'."); } } catch (IOException e) { throw new JsonException(e.getMessage(), e); } }
JsonWriter { public void writeEndObject() throws JsonException { try { JsonToken token = stack.pop(); if (token == object) { writer.write('}'); commaFirst = true; } else { throw new JsonException("Syntax error. Unexpected element '}'."); } } catch (IOException e) { throw new JsonException(e.getMessage(), e); } } }
JsonWriter { public void writeEndObject() throws JsonException { try { JsonToken token = stack.pop(); if (token == object) { writer.write('}'); commaFirst = true; } else { throw new JsonException("Syntax error. Unexpected element '}'."); } } catch (IOException e) { throw new JsonException(e.getMessage(), e); } } JsonWriter(Writer writer);  JsonWriter(OutputStream out); }
JsonWriter { public void writeEndObject() throws JsonException { try { JsonToken token = stack.pop(); if (token == object) { writer.write('}'); commaFirst = true; } else { throw new JsonException("Syntax error. Unexpected element '}'."); } } catch (IOException e) { throw new JsonException(e.getMessage(), e); } } JsonWriter(Writer writer);  JsonWriter(OutputStream out); final boolean isWriteNulls(); final void setWriteNulls(boolean writeNulls); void writeStartObject(); void writeEndObject(); void writeStartArray(); void writeEndArray(); void writeKey(String key); void writeString(String value); void writeValue(String value); void writeValue(long value); void writeValue(double value); void writeValue(boolean value); void writeNull(); void flush(); void close(); }
JsonWriter { public void writeEndObject() throws JsonException { try { JsonToken token = stack.pop(); if (token == object) { writer.write('}'); commaFirst = true; } else { throw new JsonException("Syntax error. Unexpected element '}'."); } } catch (IOException e) { throw new JsonException(e.getMessage(), e); } } JsonWriter(Writer writer);  JsonWriter(OutputStream out); final boolean isWriteNulls(); final void setWriteNulls(boolean writeNulls); void writeStartObject(); void writeEndObject(); void writeStartArray(); void writeEndArray(); void writeKey(String key); void writeString(String value); void writeValue(String value); void writeValue(long value); void writeValue(double value); void writeValue(boolean value); void writeNull(); void flush(); void close();  }