feat: add initial classes for json package

This commit is contained in:
punchready 2021-04-29 16:40:35 +02:00
parent 034d046e39
commit 47fa16b9ee
2 changed files with 50 additions and 0 deletions

View File

@ -0,0 +1,25 @@
package com.uulm.marvelous.gamelibrary.json;
import jdk.jshell.spi.ExecutionControl;
/** Contains JSON encoding and decoding.
*/
public class JSON {
/** Deserializes an incoming network message into a {@link MessageStructure}.
* @param input The JSON to deserialize.
* @return The parsed message.
*/
public static MessageStructure[] parse(String input) throws ExecutionControl.NotImplementedException {
//TODO: implement JSON.parse
throw new ExecutionControl.NotImplementedException("JSON.parse is not implemented");
}
/** Serializes a {@link MessageStructure} into a JSON string.
* @param input The message to serialize.
* @return The message as JSON.
*/
public static String stringify(MessageStructure input) throws ExecutionControl.NotImplementedException {
//TODO: implement JSON.stringify
throw new ExecutionControl.NotImplementedException("JSON.stringify is not implemented");
}
}

View File

@ -0,0 +1,25 @@
package com.uulm.marvelous.gamelibrary.json;
import com.uulm.marvelous.gamelibrary.events.Event;
import java.util.HashMap;
/** Represents a message sent between client and server and contains all possible data.
*/
public class MessageStructure {
/** The list of {@link Event}s sent inside the message.
*/
public Event[] events;
/** The checksum of the current game state at the time the message was sent.
*/
public int checksum;
/** The type of the custom content sent with the message.
*/
public String customContentType;
/** The decoded contents of the custom content sent.
*/
public HashMap<String, Object> customContent;
}