Search in sources :

Example 31 with JsonParser

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

the class MuteUserInVoiceConfRequestMessage method fromJson.

public static MuteUserInVoiceConfRequestMessage 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 (MUTE_VOICE_USER_REQUEST.equals(messageName)) {
                if (payload.has(MEETING_ID) && payload.has(VOICE_CONF_ID) && payload.has(VOICE_USER_ID) && payload.has(MUTE)) {
                    String id = payload.get(MEETING_ID).getAsString();
                    String voiceConfId = payload.get(VOICE_CONF_ID).getAsString();
                    String voiceUserId = payload.get(VOICE_USER_ID).getAsString();
                    Boolean mute = payload.get(MUTE).getAsBoolean();
                    return new MuteUserInVoiceConfRequestMessage(id, voiceConfId, voiceUserId, mute);
                }
            }
        }
    }
    return null;
}
Also used : JsonObject(com.google.gson.JsonObject) JsonParser(com.google.gson.JsonParser)

Example 32 with JsonParser

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

the class MuteUserRequestMessage method fromJson.

public static MuteUserRequestMessage 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 (MUTE_USER_REQUEST.equals(messageName)) {
                if (payload.has(MEETING_ID) && payload.has(REQUESTER_ID) && payload.has(USER_ID) && payload.has(MUTE)) {
                    String id = payload.get(MEETING_ID).getAsString();
                    String requesterId = payload.get(REQUESTER_ID).getAsString();
                    String userId = payload.get(USER_ID).getAsString();
                    Boolean mute = payload.get(MUTE).getAsBoolean();
                    return new MuteUserRequestMessage(id, requesterId, userId, mute);
                }
            }
        }
    }
    return null;
}
Also used : JsonObject(com.google.gson.JsonObject) JsonParser(com.google.gson.JsonParser)

Example 33 with JsonParser

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

the class PollCreatedMessage method fromJson.

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

Example 34 with JsonParser

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

the class PollShowResultMessage method fromJson.

public static PollShowResultMessage 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 (POLL_SHOW_RESULT.equals(messageName)) {
                if (payload.has(Constants.MEETING_ID) && payload.has(POLL)) {
                    String id = payload.get(Constants.MEETING_ID).getAsString();
                    JsonObject poll = payload.get(POLL).getAsJsonObject();
                    Util util = new Util();
                    Map<String, Object> pollMap = util.decodeSimplePollResult(poll);
                    return new PollShowResultMessage(id, pollMap);
                }
            }
        }
    }
    return null;
}
Also used : JsonObject(com.google.gson.JsonObject) JsonObject(com.google.gson.JsonObject) JsonParser(com.google.gson.JsonParser)

Example 35 with JsonParser

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

the class IsWhiteboardEnabledReplyMessage method fromJson.

public static IsWhiteboardEnabledReplyMessage 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 (IS_WHITEBOARD_ENABLED_REPLY.equals(messageName)) {
                if (payload.has(Constants.MEETING_ID) && payload.has(Constants.REQUESTER_ID) && payload.has(Constants.ENABLED)) {
                    String meetingId = payload.get(Constants.MEETING_ID).getAsString();
                    String requesterId = payload.get(Constants.REQUESTER_ID).getAsString();
                    boolean enabled = payload.get(Constants.ENABLED).getAsBoolean();
                    return new IsWhiteboardEnabledReplyMessage(meetingId, requesterId, enabled);
                }
            }
        }
    }
    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