use of com.google.gson.JsonObject in project bigbluebutton by bigbluebutton.
the class AbstractService method addHeaderToMessage.
public String addHeaderToMessage(String jsonMessage, String messageName) {
JsonObject payload = JsonEncoderUtil.buildPayload(jsonMessage);
JsonObject header = JsonEncoderUtil.addMessageHeader(messageName);
return new Gson().toJson(JsonEncoderUtil.headerAndPayload(header, payload));
}
use of com.google.gson.JsonObject in project bigbluebutton by bigbluebutton.
the class JsonEncoderUtil method addMessageHeader.
public static JsonObject addMessageHeader(String name) {
JsonObject header = new JsonObject();
header.add("name", new JsonPrimitive(name));
return header;
}
use of com.google.gson.JsonObject in project bigbluebutton by bigbluebutton.
the class CaptionClientMessageSender method handleCaptionMessage.
public void handleCaptionMessage(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");
if (header.has("name")) {
String messageName = header.get("name").getAsString();
switch(messageName) {
case SendCaptionHistoryReplyMessage.SEND_CAPTION_HISTORY_REPLY:
SendCaptionHistoryReplyMessage sch = SendCaptionHistoryReplyMessage.fromJson(message);
if (sch != null) {
processSendCaptionHistoryReplyMessage(sch);
}
break;
case UpdateCaptionOwnerMessage.UPDATE_CAPTION_OWNER:
UpdateCaptionOwnerMessage uco = UpdateCaptionOwnerMessage.fromJson(message);
if (uco != null) {
processUpdateCaptionOwnerMessage(uco);
}
break;
case EditCaptionHistoryMessage.EDIT_CAPTION_HISTORY:
EditCaptionHistoryMessage ech = EditCaptionHistoryMessage.fromJson(message);
if (ech != null) {
processEditCaptionHistoryMessage(ech);
}
break;
}
}
}
}
use of com.google.gson.JsonObject in project KeyBox by skavanagh.
the class SessionOutputSerializer method serialize.
@Override
public JsonElement serialize(Object src, Type typeOfSrc, JsonSerializationContext context) {
JsonObject object = new JsonObject();
if (typeOfSrc.equals(AuditWrapper.class)) {
AuditWrapper auditWrapper = (AuditWrapper) src;
object.addProperty("user_id", auditWrapper.getUser().getId());
object.addProperty("username", auditWrapper.getUser().getUsername());
object.addProperty("user_type", auditWrapper.getUser().getUserType());
object.addProperty("first_nm", auditWrapper.getUser().getFirstNm());
object.addProperty("last_nm", auditWrapper.getUser().getLastNm());
object.addProperty("email", auditWrapper.getUser().getEmail());
object.addProperty("session_id", auditWrapper.getSessionOutput().getSessionId());
object.addProperty("instance_id", auditWrapper.getSessionOutput().getInstanceId());
object.addProperty("host_id", auditWrapper.getSessionOutput().getId());
object.addProperty("host", auditWrapper.getSessionOutput().getDisplayLabel());
object.addProperty("output", auditWrapper.getSessionOutput().getOutput().toString());
object.addProperty("timestamp", new Date().getTime());
}
return object;
}
use of com.google.gson.JsonObject in project androidquery by androidquery.
the class AQueryAsyncTest method testAjaxPostRaw.
public void testAjaxPostRaw() throws UnsupportedEncodingException {
String url = "http://www.androidquery.com/p/doNothing";
List<NameValuePair> pairs = new ArrayList<NameValuePair>();
pairs.add(new BasicNameValuePair("q", "androidquery"));
HttpEntity entity = new UrlEncodedFormEntity(pairs, "UTF-8");
Map<String, Object> params = new HashMap<String, Object>();
params.put(AQuery.POST_ENTITY, entity);
aq.ajax(url, params, JSONObject.class, new AjaxCallback<JSONObject>() {
@Override
public void callback(String url, JSONObject jo, AjaxStatus status) {
done(url, jo, status);
}
});
waitAsync();
JSONObject jo = (JSONObject) result;
assertNotNull(jo);
assertNotNull(jo.opt("params"));
assertEquals("POST", jo.optString("method"));
}
Aggregations