refactor: refactored JSON class for new messages
This commit is contained in:
parent
c67968896b
commit
4823803e85
@ -23,14 +23,15 @@ public class JSON {
|
|||||||
|
|
||||||
/** Deserializes an incoming network message into a {@link EventMessage}.
|
/** Deserializes an incoming network message into a {@link EventMessage}.
|
||||||
* @param input The JSON to deserialize
|
* @param input The JSON to deserialize
|
||||||
* @return The parsed message or {@code null} if the deserialization failed
|
* @return The parsed message (as {@link BasicMessage}, so casting is necessary)
|
||||||
|
* or {@code null} if the deserialization failed
|
||||||
*/
|
*/
|
||||||
public EventMessage parse(String input) {
|
public BasicMessage parse(String input) {
|
||||||
EventMessage result = null;
|
BasicMessage result = null;
|
||||||
try {
|
try {
|
||||||
return mapper.readValue(input, EventMessage.class);
|
return mapper.readValue(input, BasicMessage.class);
|
||||||
} catch (JsonProcessingException e) {
|
} catch (JsonProcessingException e) {
|
||||||
e.printStackTrace();
|
// e.printStackTrace();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -43,7 +44,7 @@ public class JSON {
|
|||||||
try {
|
try {
|
||||||
return mapper.writeValueAsString(input);
|
return mapper.writeValueAsString(input);
|
||||||
} catch (JsonProcessingException e) {
|
} catch (JsonProcessingException e) {
|
||||||
e.printStackTrace();
|
// e.printStackTrace();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user