@Test public void deserializeTest() throws IOException { String json = "[3, {\"message\": \"The realm does not exist.\"}, \"wamp.error.no_such_realm\"]"; AbortMessage abortMessage = WampMessage.deserialize(getJsonFactory(), json.getBytes(StandardCharsets.UTF_8)); assertThat(abortMessage.getCode()).isEqualTo(3); assertThat(abortMessage.getMessage()).isEqualTo("The realm does not exist."); assertThat(abortMessage.getReason()).isEqualTo("wamp.error.no_such_realm"); json = "[3, {}, \"wamp.error.no_such_realm\"]"; abortMessage = WampMessage.deserialize(getJsonFactory(), json.getBytes(StandardCharsets.UTF_8)); assertThat(abortMessage.getCode()).isEqualTo(3); assertThat(abortMessage.getMessage()).isNull(); assertThat(abortMessage.getReason()).isEqualTo("wamp.error.no_such_realm"); }
public static AbortMessage deserialize(JsonParser jp) throws IOException { String msg = null; jp.nextToken(); Map<String, Object> details = ParserUtil.readObject(jp); if (details != null) { msg = (String) details.get("message"); } jp.nextToken(); return new AbortMessage(jp.getValueAsString(), msg); }
AbortMessage extends WampMessage { public static AbortMessage deserialize(JsonParser jp) throws IOException { String msg = null; jp.nextToken(); Map<String, Object> details = ParserUtil.readObject(jp); if (details != null) { msg = (String) details.get("message"); } jp.nextToken(); return new AbortMessage(jp.getValueAsString(), msg); } }
AbortMessage extends WampMessage { public static AbortMessage deserialize(JsonParser jp) throws IOException { String msg = null; jp.nextToken(); Map<String, Object> details = ParserUtil.readObject(jp); if (details != null) { msg = (String) details.get("message"); } jp.nextToken(); return new AbortMessage(jp.getValueAsString(), msg); } AbortMessage(WampError reason, @Nullable String message);  AbortMessage(WampError reason); private  AbortMessage(String reason, @Nullable String message); }
AbortMessage extends WampMessage { public static AbortMessage deserialize(JsonParser jp) throws IOException { String msg = null; jp.nextToken(); Map<String, Object> details = ParserUtil.readObject(jp); if (details != null) { msg = (String) details.get("message"); } jp.nextToken(); return new AbortMessage(jp.getValueAsString(), msg); } AbortMessage(WampError reason, @Nullable String message);  AbortMessage(WampError reason); private  AbortMessage(String reason, @Nullable String message); static AbortMessage deserialize(JsonParser jp); @Override void serialize(JsonGenerator generator); @Nullable String getMessage(); @Nullable String getReason(); @Override String toString(); }
AbortMessage extends WampMessage { public static AbortMessage deserialize(JsonParser jp) throws IOException { String msg = null; jp.nextToken(); Map<String, Object> details = ParserUtil.readObject(jp); if (details != null) { msg = (String) details.get("message"); } jp.nextToken(); return new AbortMessage(jp.getValueAsString(), msg); } AbortMessage(WampError reason, @Nullable String message);  AbortMessage(WampError reason); private  AbortMessage(String reason, @Nullable String message); static AbortMessage deserialize(JsonParser jp); @Override void serialize(JsonGenerator generator); @Nullable String getMessage(); @Nullable String getReason(); @Override String toString();  }