File tree Expand file tree Collapse file tree 2 files changed +9
-13
lines changed
client/src/org/openqa/selenium/json
server/src/org/openqa/selenium/remote/server/rest Expand file tree Collapse file tree 2 files changed +9
-13
lines changed Original file line number Diff line number Diff line change 21
21
import com .google .common .reflect .TypeToken ;
22
22
import com .google .gson .Gson ;
23
23
import com .google .gson .GsonBuilder ;
24
- import com .google .gson .JsonElement ;
25
24
26
25
import java .io .IOException ;
27
26
import java .io .Reader ;
32
31
import java .util .Map ;
33
32
34
33
public class Json {
35
- final static Gson GSON = new GsonBuilder ()
34
+ static final Gson GSON = new GsonBuilder ()
36
35
.setLenient ()
37
36
.serializeNulls ()
38
37
.disableHtmlEscaping ()
@@ -49,14 +48,6 @@ public String toJson(Object toConvert) {
49
48
return toJson .convert (toConvert );
50
49
}
51
50
52
- /**
53
- * @deprecated No replacement. Use raw java types instead.
54
- */
55
- @ Deprecated
56
- public JsonElement toJsonElement (Object toConvert ) {
57
- return toJson .convertObject (toConvert );
58
- }
59
-
60
51
public <T > T toType (String source , Type typeOfT ) {
61
52
return toType (source , typeOfT , PropertySetting .BY_NAME );
62
53
}
Original file line number Diff line number Diff line change 17
17
18
18
package org .openqa .selenium .remote .server .rest ;
19
19
20
+ import static org .openqa .selenium .json .Json .MAP_TYPE ;
21
+
20
22
import com .google .gson .JsonObject ;
21
23
22
24
import org .openqa .selenium .json .Json ;
23
25
import org .openqa .selenium .remote .ErrorCodes ;
24
26
import org .openqa .selenium .remote .Response ;
25
27
import org .openqa .selenium .remote .SessionId ;
26
28
29
+ import java .util .Map ;
27
30
import java .util .Optional ;
28
31
29
32
/**
@@ -83,9 +86,11 @@ public static Response failure(
83
86
response .setState (ERROR_CODES .toState (response .getStatus ()));
84
87
85
88
if (reason != null ) {
86
- JsonObject json = new Json ().toJsonElement (reason ).getAsJsonObject ();
87
- screenshot .ifPresent (screen -> json .addProperty ("screen" , screen ));
88
- response .setValue (json );
89
+ Json json = new Json ();
90
+ String raw = json .toJson (reason );
91
+ Map <String , Object > value = json .toType (raw , MAP_TYPE );
92
+ screenshot .ifPresent (screen -> value .put ("screen" , screen ));
93
+ response .setValue (value );
89
94
}
90
95
return response ;
91
96
}
You can’t perform that action at this time.
0 commit comments