List of usage examples for com.google.gson JsonSerializationContext serialize
public JsonElement serialize(Object src);
From source file:sbu.srl.datastructure.ILPSRLDataSerializer.java
@Override public JsonElement serialize(JSONData data, Type type, JsonSerializationContext context) { final JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("process", data.getProcessName()); final JsonElement jsonSentences = context.serialize(data.getSentence()); jsonObject.add("sentences", jsonSentences); return jsonObject; }
From source file:sbu.srl.datastructure.SentenceSerializer.java
@Override public JsonElement serialize(Sentence s, Type type, JsonSerializationContext context) { final JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("sentenceId", s.getId()); jsonObject.addProperty("text", s.getRawText()); ArrayList<ArgumentSpan> annotatedArgumentSpans = null; ArrayList<ArgumentSpan> predictedArgumentSpans = (s.getAllPredictedArgumentSpan() == null ? s.getPredictedArgumentSpanJSON() : s.getAllPredictedArgumentSpan()); JsonElement jsonArgumentSpans = null; if (!predict) { annotatedArgumentSpans = s.getAllAnnotatedArgumentSpan(); Collections.sort(annotatedArgumentSpans); jsonArgumentSpans = context.serialize(annotatedArgumentSpans); }/*from w w w . j a v a 2s .c om*/ if (predictedArgumentSpans == null) predictedArgumentSpans = new ArrayList<ArgumentSpan>(); final JsonElement jsonPredictedArgumentSpans = context.serialize(predictedArgumentSpans); // IF if (!predict) jsonObject.add("annotatedArgumentSpan", jsonArgumentSpans); jsonObject.add("predictionArgumentSpan", jsonPredictedArgumentSpans); return jsonObject; }
From source file:se.kth.karamel.backend.running.model.serializers.AbstractTaskSerializer.java
@Override public JsonElement serialize(Task task, Type type, JsonSerializationContext context) { final JsonObject jsonObj = new JsonObject(); jsonObj.add("task", context.serialize(task.getName())); jsonObj.add("status", context.serialize(task.getStatus().toString())); addExtraFields(jsonObj);// w w w.java2 s .c o m try { List<ShellCommand> commands = task.getCommands(); jsonObj.add("commands", context.serialize(commands)); } catch (IOException ex) { } return jsonObj; }
From source file:se.kth.karamel.backend.running.model.serializers.ClusterEntitySerializer.java
@Override public JsonElement serialize(ClusterRuntime clusterEntity, Type type, JsonSerializationContext context) { final JsonObject jsonObj = new JsonObject(); jsonObj.add("cluster", context.serialize(clusterEntity.getName())); jsonObj.add("phase", context.serialize(clusterEntity.getPhase().toString())); if (clusterEntity.isFailed()) { jsonObj.add("failed", context.serialize(clusterEntity.isFailed())); }/*from w w w .j a va 2 s . c om*/ if (clusterEntity.isPaused()) { jsonObj.add("paused", context.serialize(clusterEntity.isPaused())); } jsonObj.add("groups", context.serialize(clusterEntity.getGroups())); return jsonObj; }
From source file:se.kth.karamel.backend.running.model.serializers.GroupEntitySerializer.java
@Override public JsonElement serialize(GroupRuntime groupEntity, Type type, JsonSerializationContext context) { final JsonObject jsonObj = new JsonObject(); jsonObj.add("group", context.serialize(groupEntity.getName())); jsonObj.add("phase", context.serialize(groupEntity.getPhase().toString())); jsonObj.add("machines", context.serialize(groupEntity.getMachines())); return jsonObj; }
From source file:se.kth.karamel.backend.running.model.serializers.MachineEntitySerializer.java
@Override public JsonElement serialize(MachineRuntime machineEntity, Type type, JsonSerializationContext context) { final JsonObject jsonObj = new JsonObject(); jsonObj.add("machine", context.serialize(machineEntity.getPublicIp())); jsonObj.add("life", context.serialize(machineEntity.getLifeStatus().toString())); jsonObj.add("tasksStatus", context.serialize(machineEntity.getTasksStatus().toString())); jsonObj.add("privateIp", context.serialize(machineEntity.getPrivateIp())); jsonObj.add("user", context.serialize(machineEntity.getSshUser())); jsonObj.add("port", context.serialize(machineEntity.getSshPort())); jsonObj.add("tasks", context.serialize(machineEntity.getTasks())); return jsonObj; }
From source file:se.kth.karamel.backend.running.model.serializers.ShellCommandSerializer.java
@Override public JsonElement serialize(ShellCommand cmd, Type type, JsonSerializationContext context) { final JsonObject jsonObj = new JsonObject(); jsonObj.add("status", context.serialize(cmd.getStatus().toString())); jsonObj.add("cmdStr", context.serialize(cmd.getCmdStr())); return jsonObj; }
From source file:uk.ac.horizon.aestheticodes.controllers.MarkerMapAdapter.java
License:Open Source License
@Override public JsonElement serialize(Map<String, Marker> src, Type typeOfSrc, JsonSerializationContext context) { final JsonArray array = new JsonArray(); for (Marker marker : src.values()) { array.add(context.serialize(marker)); }//from w w w.j av a 2 s . com return array; }
From source file:uk.ac.ncl.aries.entanglement.revlog.RevisionItemSerializer.java
License:Apache License
@Override public JsonElement serialize(RevisionItem t, Type type, JsonSerializationContext jsc) { return jsc.serialize(t); }
From source file:uk.ac.susx.tag.method51.core.GsonOptionalSerializer.java
License:Apache License
@Override public JsonElement serialize(Optional<T> src, Type typeOfSrc, JsonSerializationContext context) { final JsonElement element = context.serialize(src.orNull()); return element; }