Search in sources :

Example 66 with JsonObject

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

the class DeskShareHangUpEventMessage method fromJson.

public static DeskShareHangUpEventMessage 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 (DESKSHARE_HANG_UP_MESSAGE.equals(messageName)) {
                if (payload.has(CONFERENCE_NAME) && payload.has(FS_CONFERENCE_NAME) && payload.has(TIMESTAMP)) {
                    String conferenceName = payload.get(CONFERENCE_NAME).getAsString();
                    String fsConferenceName = payload.get(FS_CONFERENCE_NAME).getAsString();
                    String timestamp = payload.get(TIMESTAMP).getAsString();
                    return new DeskShareHangUpEventMessage(conferenceName, fsConferenceName, timestamp);
                }
            }
        }
    }
    return null;
}
Also used : JsonObject(com.google.gson.JsonObject) JsonParser(com.google.gson.JsonParser)

Example 67 with JsonObject

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

the class EjectUserFromVoiceConfRequestMessage method fromJson.

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

Example 68 with JsonObject

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

the class EditCaptionHistoryMessage method fromJson.

public static EditCaptionHistoryMessage 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 (EDIT_CAPTION_HISTORY.equals(messageName)) {
                if (payload.has(Constants.MEETING_ID) && payload.has(Constants.USER_ID) && payload.has(Constants.START_INDEX) && payload.has(Constants.END_INDEX) && payload.has(Constants.LOCALE) && payload.has(Constants.LOCALE_CODE) && payload.has(Constants.TEXT)) {
                    String meetingID = payload.get(Constants.MEETING_ID).getAsString();
                    String userID = payload.get(Constants.USER_ID).getAsString();
                    Integer startIndex = payload.get(Constants.START_INDEX).getAsInt();
                    Integer endIndex = payload.get(Constants.END_INDEX).getAsInt();
                    String locale = payload.get(Constants.LOCALE).getAsString();
                    String localeCode = payload.get(Constants.LOCALE_CODE).getAsString();
                    String text = payload.get(Constants.TEXT).getAsString();
                    return new EditCaptionHistoryMessage(meetingID, userID, startIndex, endIndex, locale, localeCode, text);
                }
            }
        }
    }
    return null;
}
Also used : JsonObject(com.google.gson.JsonObject) JsonParser(com.google.gson.JsonParser)

Example 69 with JsonObject

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

the class EjectAllUsersFromVoiceConfRequestMessage method fromJson.

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

Example 70 with JsonObject

use of com.google.gson.JsonObject in project disunity by ata4.

the class JsonTablePrinter method tableToJson.

private JsonArray tableToJson(Table<Integer, Integer, Object> table, Gson gson) {
    JsonArray jsonTable = new JsonArray();
    table.rowMap().forEach((rk, r) -> {
        if (rk == 0) {
            return;
        }
        JsonObject jsonRow = new JsonObject();
        table.columnMap().forEach((ck, c) -> {
            String key = String.valueOf(table.get(0, ck)).toLowerCase();
            Object value = table.get(rk, ck);
            jsonRow.add(key, gson.toJsonTree(value));
        });
        jsonTable.add(jsonRow);
    });
    JsonObject jsonRoot = new JsonObject();
    if (file != null) {
        jsonRoot.add("file", new JsonPrimitive(file.toString()));
    }
    return jsonTable;
}
Also used : JsonArray(com.google.gson.JsonArray) JsonPrimitive(com.google.gson.JsonPrimitive) JsonObject(com.google.gson.JsonObject) JsonObject(com.google.gson.JsonObject)

Aggregations

JsonObject (com.google.gson.JsonObject)1417 JsonElement (com.google.gson.JsonElement)389 JsonArray (com.google.gson.JsonArray)293 JsonParser (com.google.gson.JsonParser)285 JsonPrimitive (com.google.gson.JsonPrimitive)137 Gson (com.google.gson.Gson)91 Test (org.junit.Test)81 HashMap (java.util.HashMap)79 Map (java.util.Map)78 ArrayList (java.util.ArrayList)77 IOException (java.io.IOException)66 Test (org.testng.annotations.Test)61 InputStreamReader (java.io.InputStreamReader)38 JsonParseException (com.google.gson.JsonParseException)27 File (java.io.File)25 List (java.util.List)21 HttpResponse (org.apache.http.HttpResponse)21 JsonReader (com.google.gson.stream.JsonReader)19 InvalidArgumentException (com.pratilipi.common.exception.InvalidArgumentException)19 InputStream (java.io.InputStream)19