Search in sources :

Example 36 with JsonParser

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

the class LockLayoutRequestMessage method fromJson.

public static LockLayoutRequestMessage 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 (LOCK_LAYOUT_REQUEST.equals(messageName)) {
                if (payload.has(Constants.MEETING_ID) && payload.has(Constants.USER_ID) && payload.has(LOCK) && payload.has(VIEWERS_ONLY) && payload.has(LAYOUT)) {
                    String id = payload.get(Constants.MEETING_ID).getAsString();
                    String userid = payload.get(Constants.USER_ID).getAsString();
                    Boolean lock = payload.get(LOCK).getAsBoolean();
                    Boolean viewersOnly = payload.get(VIEWERS_ONLY).getAsBoolean();
                    String layout = payload.get(LAYOUT).getAsString();
                    return new LockLayoutRequestMessage(id, userid, lock, viewersOnly, layout);
                }
            }
        }
    }
    return null;
}
Also used : JsonObject(com.google.gson.JsonObject) JsonParser(com.google.gson.JsonParser)

Example 37 with JsonParser

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

the class LockUserMessage method fromJson.

public static LockUserMessage 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 (LOCK_USER.equals(messageName)) {
                if (payload.has(Constants.MEETING_ID) && payload.has(Constants.REQUESTER_ID) && payload.has(Constants.LOCK) && payload.has(Constants.INTERNAL_USER_ID)) {
                    String meetingId = payload.get(Constants.MEETING_ID).getAsString();
                    String requesterId = payload.get(Constants.REQUESTER_ID).getAsString();
                    boolean lock = payload.get(Constants.LOCK).getAsBoolean();
                    String internalUserId = payload.get(Constants.INTERNAL_USER_ID).getAsString();
                    return new LockUserMessage(meetingId, requesterId, lock, internalUserId);
                }
            }
        }
    }
    return null;
}
Also used : JsonObject(com.google.gson.JsonObject) JsonParser(com.google.gson.JsonParser)

Example 38 with JsonParser

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

the class StartPollRequestMessage method fromJson.

public static StartPollRequestMessage 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 (START_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 StartPollRequestMessage(id, requesterId, pollId, pollType);
                }
            }
        }
    }
    return null;
}
Also used : JsonObject(com.google.gson.JsonObject) JsonParser(com.google.gson.JsonParser)

Example 39 with JsonParser

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

the class StopPollRequestMessage method fromJson.

public static StopPollRequestMessage 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 (STOP_POLL_REQUEST.equals(messageName)) {
                if (payload.has(Constants.MEETING_ID) && payload.has(REQUESTER_ID) && payload.has(POLL_ID)) {
                    String id = payload.get(Constants.MEETING_ID).getAsString();
                    String requesterId = payload.get(REQUESTER_ID).getAsString();
                    String pollId = payload.get(POLL_ID).getAsString();
                    return new StopPollRequestMessage(id, requesterId, pollId);
                }
            }
        }
    }
    return null;
}
Also used : JsonObject(com.google.gson.JsonObject) JsonParser(com.google.gson.JsonParser)

Example 40 with JsonParser

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

the class TransferUserToVoiceConfRequestMessage method fromJson.

public static TransferUserToVoiceConfRequestMessage 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 (TRANSFER_USER_TO_VOICE_CONF_REQUEST.equals(messageName)) {
                if (payload.has(VOICE_CONF_ID) && payload.has(TARGET_VOICE_CONF_ID) && payload.has(VOICE_USER_ID)) {
                    String id = payload.get(VOICE_CONF_ID).getAsString();
                    String targetVoiceConfId = payload.get(TARGET_VOICE_CONF_ID).getAsString();
                    String voiceUserId = payload.get(VOICE_USER_ID).getAsString();
                    return new TransferUserToVoiceConfRequestMessage(id, targetVoiceConfId, voiceUserId);
                }
            }
        }
    }
    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