MCPcopy Create free account
hub / github.com/SeleniumHQ/selenium / fromJson

Method fromJson

java/src/org/openqa/selenium/remote/Response.java:83–112  ·  view source on GitHub ↗
(Map<String, Object> json)

Source from the content-addressed store, hash-verified

81 }
82
83 private static Response fromJson(Map<String, Object> json) {
84 Response response = new Response();
85
86 if (json.get("error") instanceof String) {
87 response.setState((String) json.get("error"));
88 response.setValue(json.get("message"));
89 }
90
91 if (json.get("state") instanceof String) {
92 response.setState((String) json.get("state"));
93 }
94
95 if (json.get("status") != null) {
96 Object status = json.get("status");
97 if (status instanceof String) {
98 response.setState((String) status);
99 } else {
100 // JSON Wire payloads carry an integer status; read it, but only as the W3C state.
101 response.setState(new ErrorCodes().toState(((Number) status).intValue()));
102 }
103 }
104
105 if (json.get("sessionId") instanceof String) {
106 response.setSessionId((String) json.get("sessionId"));
107 }
108
109 response.setValue(json.getOrDefault("value", json));
110
111 return response;
112 }
113}

Callers

nothing calls this directly

Calls 5

setStateMethod · 0.95
setValueMethod · 0.95
setSessionIdMethod · 0.95
toStateMethod · 0.80
getMethod · 0.65

Tested by

no test coverage detected