Skip to content

Commit

Permalink
Avoid using the BeanToJsonConverter within Json
Browse files Browse the repository at this point in the history
  • Loading branch information
shs96c committed May 14, 2018
1 parent 2c2db8a commit ade980b
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion java/client/src/org/openqa/selenium/json/Json.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@
import java.io.IOException;
import java.io.Reader;
import java.io.StringReader;
import java.io.StringWriter;
import java.io.UncheckedIOException;
import java.io.Writer;
import java.lang.reflect.Type;
import java.util.List;
import java.util.Map;
Expand All @@ -45,7 +47,13 @@ public class Json {
private final BeanToJsonConverter toJson = new BeanToJsonConverter();

public String toJson(Object toConvert) {
return toJson.convert(toConvert);
try (Writer writer = new StringWriter();
JsonOutput jsonOutput = newOutput(writer)) {
jsonOutput.write(toConvert);
return writer.toString();
} catch (IOException e) {
throw new JsonException(e);
}
}

public <T> T toType(String source, Type typeOfT) {
Expand Down

0 comments on commit ade980b

Please sign in to comment.