@Test public void failsWriteStartObjectWhenItDoesNotStartRootObjectOrDoesNotFollowKey() throws Exception { jsonWriter.writeStartObject(); thrown.expect(JsonException.class); jsonWriter.writeStartObject(); }
public void writeStartObject() throws JsonException { writeCurrentKey(); JsonToken token = stack.peek(); if (token == null || token == key || token == array) { try { if (commaFirst) { writer.write(','); } writer.write('{'); if (token == key) { stack.pop(); } stack.push(object); commaFirst = false; } catch (IOException e) { throw new JsonException(e.getMessage(), e); } } else { throw new JsonException("Syntax error. Unexpected element '{'."); } }
JsonWriter { public void writeStartObject() throws JsonException { writeCurrentKey(); JsonToken token = stack.peek(); if (token == null || token == key || token == array) { try { if (commaFirst) { writer.write(','); } writer.write('{'); if (token == key) { stack.pop(); } stack.push(object); commaFirst = false; } catch (IOException e) { throw new JsonException(e.getMessage(), e); } } else { throw new JsonException("Syntax error. Unexpected element '{'."); } } }
JsonWriter { public void writeStartObject() throws JsonException { writeCurrentKey(); JsonToken token = stack.peek(); if (token == null || token == key || token == array) { try { if (commaFirst) { writer.write(','); } writer.write('{'); if (token == key) { stack.pop(); } stack.push(object); commaFirst = false; } catch (IOException e) { throw new JsonException(e.getMessage(), e); } } else { throw new JsonException("Syntax error. Unexpected element '{'."); } } JsonWriter(Writer writer);  JsonWriter(OutputStream out); }
JsonWriter { public void writeStartObject() throws JsonException { writeCurrentKey(); JsonToken token = stack.peek(); if (token == null || token == key || token == array) { try { if (commaFirst) { writer.write(','); } writer.write('{'); if (token == key) { stack.pop(); } stack.push(object); commaFirst = false; } catch (IOException e) { throw new JsonException(e.getMessage(), e); } } else { throw new JsonException("Syntax error. Unexpected element '{'."); } } 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 writeStartObject() throws JsonException { writeCurrentKey(); JsonToken token = stack.peek(); if (token == null || token == key || token == array) { try { if (commaFirst) { writer.write(','); } writer.write('{'); if (token == key) { stack.pop(); } stack.push(object); commaFirst = false; } catch (IOException e) { throw new JsonException(e.getMessage(), e); } } else { throw new JsonException("Syntax error. Unexpected element '{'."); } } 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();  }