Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,10 @@ private void put(JsonElement value) {
return this;
}

@Override public JsonWriter jsonValue(String value) throws IOException {
throw new UnsupportedOperationException();
}

@Override public JsonWriter nullValue() throws IOException {
put(JsonNull.INSTANCE);
return this;
Expand Down
5 changes: 4 additions & 1 deletion gson/src/main/java/com/google/gson/stream/JsonWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -426,10 +426,13 @@ public JsonWriter value(String value) throws IOException {

/**
* Writes {@code value} directly to the writer without quoting or
* escaping.
* escaping. This might not be supported by all implementations, if
* not supported an {@code UnsupportedOperationException} is thrown.
*
* @param value the literal string value, or null to encode a null literal.
* @return this writer.
* @throws UnsupportedOperationException if this writer does not support
* writing raw JSON values.
*/
public JsonWriter jsonValue(String value) throws IOException {
if (value == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,4 +233,14 @@ public void testStrictBoxedNansAndInfinities() throws IOException {
} catch (IllegalArgumentException expected) {
}
}

public void testJsonValue() throws IOException {
JsonTreeWriter writer = new JsonTreeWriter();
writer.beginArray();
try {
writer.jsonValue("test");
fail();
} catch (UnsupportedOperationException expected) {
}
}
}