Search in sources :

Example 56 with JsonParser

use of com.google.gson.JsonParser in project bigbluebutton by bigbluebutton.

the class DeskShareStoppedEventMessage method fromJson.

public static DeskShareStoppedEventMessage fromJson(String message) {
    JsonParser parser = new JsonParser();
    JsonObject obj = (JsonObject) parser.parse(message);
    if (obj.has("header") && obj.has("payload")) {
        JsonObject header = (JsonObject) obj.get("header");
        JsonObject payload = (JsonObject) obj.get("payload");
        if (header.has("name")) {
            String messageName = header.get("name").getAsString();
            if (DESK_SHARE_STOPPED_MESSAGE.equals(messageName)) {
                if (payload.has(CONFERENCE_NAME) && payload.has(CALLER_ID) && payload.has(CALLER_ID_NAME)) {
                    String conferenceName = payload.get(CONFERENCE_NAME).getAsString();
                    String callerId = payload.get(CALLER_ID_NAME).getAsString();
                    String callerIdName = payload.get(CALLER_ID_NAME).getAsString();
                    return new DeskShareStoppedEventMessage(conferenceName, callerId, callerIdName);
                }
            }
        }
    }
    return null;
}
Also used : JsonObject(com.google.gson.JsonObject) JsonParser(com.google.gson.JsonParser)

Example 57 with JsonParser

use of com.google.gson.JsonParser in project bigbluebutton by bigbluebutton.

the class DisconnectAllUsersMessage method fromJson.

public static DisconnectAllUsersMessage fromJson(String message) {
    JsonParser parser = new JsonParser();
    JsonObject obj = (JsonObject) parser.parse(message);
    if (obj.has("header") && obj.has("payload")) {
        JsonObject header = (JsonObject) obj.get("header");
        JsonObject payload = (JsonObject) obj.get("payload");
        if (header.has("name")) {
            String messageName = header.get("name").getAsString();
            if (DISCONNECT_All_USERS.equals(messageName)) {
                if (payload.has(Constants.MEETING_ID)) {
                    String meetingId = payload.get(Constants.MEETING_ID).getAsString();
                    return new DisconnectAllUsersMessage(meetingId);
                }
            }
        }
    }
    return null;
}
Also used : JsonObject(com.google.gson.JsonObject) JsonParser(com.google.gson.JsonParser)

Example 58 with JsonParser

use of com.google.gson.JsonParser in project bigbluebutton by bigbluebutton.

the class ClearWhiteboardReplyMessage method fromJson.

public static ClearWhiteboardReplyMessage fromJson(String message) {
    JsonParser parser = new JsonParser();
    JsonObject obj = (JsonObject) parser.parse(message);
    if (obj.has("header") && obj.has("payload")) {
        JsonObject header = (JsonObject) obj.get("header");
        JsonObject payload = (JsonObject) obj.get("payload");
        if (header.has("name")) {
            String messageName = header.get("name").getAsString();
            if (WHITEBOARD_CLEARED_MESSAGE.equals(messageName)) {
                if (payload.has(Constants.MEETING_ID) && payload.has(Constants.WHITEBOARD_ID) && payload.has(Constants.REQUESTER_ID)) {
                    String meetingId = payload.get(Constants.MEETING_ID).getAsString();
                    String whiteboardId = payload.get(Constants.WHITEBOARD_ID).getAsString();
                    String requesterId = payload.get(Constants.REQUESTER_ID).getAsString();
                    return new ClearWhiteboardReplyMessage(meetingId, requesterId, whiteboardId);
                }
            }
        }
    }
    return null;
}
Also used : JsonObject(com.google.gson.JsonObject) JsonParser(com.google.gson.JsonParser)

Example 59 with JsonParser

use of com.google.gson.JsonParser in project bigbluebutton by bigbluebutton.

the class ClearWhiteboardRequestMessage method fromJson.

public static ClearWhiteboardRequestMessage fromJson(String message) {
    JsonParser parser = new JsonParser();
    JsonObject obj = (JsonObject) parser.parse(message);
    if (obj.has("header") && obj.has("payload")) {
        JsonObject header = (JsonObject) obj.get("header");
        JsonObject payload = (JsonObject) obj.get("payload");
        if (header.has("name")) {
            String messageName = header.get("name").getAsString();
            if (CLEAR_WHITEBOARD_REQUEST.equals(messageName)) {
                if (payload.has(Constants.MEETING_ID) && payload.has(Constants.WHITEBOARD_ID) && payload.has(Constants.REQUESTER_ID)) {
                    String meetingId = payload.get(Constants.MEETING_ID).getAsString();
                    String whiteboardId = payload.get(Constants.WHITEBOARD_ID).getAsString();
                    String requesterId = payload.get(Constants.REQUESTER_ID).getAsString();
                    return new ClearWhiteboardRequestMessage(meetingId, requesterId, whiteboardId);
                }
            }
        }
    }
    return null;
}
Also used : JsonObject(com.google.gson.JsonObject) JsonParser(com.google.gson.JsonParser)

Example 60 with JsonParser

use of com.google.gson.JsonParser in project bigbluebutton by bigbluebutton.

the class CreatePollRequestMessage method fromJson.

public static CreatePollRequestMessage fromJson(String message) {
    JsonParser parser = new JsonParser();
    JsonObject obj = (JsonObject) parser.parse(message);
    if (obj.has("header") && obj.has("payload")) {
        JsonObject header = (JsonObject) obj.get("header");
        JsonObject payload = (JsonObject) obj.get("payload");
        if (header.has("name")) {
            String messageName = header.get("name").getAsString();
            if (CREATE_POLL_REQUEST.equals(messageName)) {
                if (payload.has(Constants.MEETING_ID) && payload.has(REQUESTER_ID) && payload.has(POLL_ID) && payload.has(POLL_TYPE)) {
                    String id = payload.get(Constants.MEETING_ID).getAsString();
                    String requesterId = payload.get(REQUESTER_ID).getAsString();
                    String pollId = payload.get(POLL_ID).getAsString();
                    String pollType = payload.get(POLL_TYPE).getAsString();
                    return new CreatePollRequestMessage(id, requesterId, pollId, pollType);
                }
            }
        }
    }
    return null;
}
Also used : JsonObject(com.google.gson.JsonObject) JsonParser(com.google.gson.JsonParser)

Aggregations

JsonParser (com.google.gson.JsonParser)356 JsonObject (com.google.gson.JsonObject)285 JsonElement (com.google.gson.JsonElement)105 JsonArray (com.google.gson.JsonArray)57 IOException (java.io.IOException)43 Gson (com.google.gson.Gson)40 InputStreamReader (java.io.InputStreamReader)32 ArrayList (java.util.ArrayList)20 HashMap (java.util.HashMap)20 Map (java.util.Map)18 Type (java.lang.reflect.Type)15 JsonReader (com.google.gson.stream.JsonReader)12 Test (org.junit.Test)12 URL (java.net.URL)11 AssetManager (android.content.res.AssetManager)10 InputStream (java.io.InputStream)10 GsonBuilder (com.google.gson.GsonBuilder)9 UserType (com.glitchcog.fontificator.bot.UserType)8 EmojiType (com.glitchcog.fontificator.emoji.EmojiType)8 JsonParseException (com.google.gson.JsonParseException)8