Java Code Examples for com.google.gson.JsonSerializationContext#serialize()
The following examples show how to use
com.google.gson.JsonSerializationContext#serialize() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DiscriminatedTypeAdapter.java From icure-backend with GNU General Public License v2.0 | 5 votes |
public JsonElement serialize(T object, Type typeOfSrc, JsonSerializationContext context) { JsonElement el = context.serialize(object, object.getClass()); JsonObject result = el.getAsJsonObject(); String discr = reverseSubclasses.get(object.getClass()); if (discr == null) { throw new JsonParseException("Invalid subclass " + object.getClass()); } result.addProperty(discriminator, discr); return result; }
Example 2
Source File: MeshNetworkDeserializer.java From Android-nRF-Mesh-Library with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Returns serialized json element containing the allocated scene ranges * * @param context Serializer context * @param ranges Allocated scene range */ private JsonElement serializeAllocatedSceneRanges(@NonNull final JsonSerializationContext context, @NonNull final List<AllocatedSceneRange> ranges) { final Type allocatedSceneRanges = new TypeToken<List<AllocatedSceneRange>>() { }.getType(); return context.serialize(ranges, allocatedSceneRanges); }
Example 3
Source File: SourceInfoSerializer.java From paintera with GNU General Public License v2.0 | 5 votes |
@Override public JsonElement serialize(final SourceInfo src, final Type typeOfSrc, final JsonSerializationContext context) { final Map<String, Object> elements = new HashMap<>(); final List<Source<?>> sources = new ArrayList<>(src.trackSources()); LOG.debug("Serializing sources: {}", sources); final List<JsonElement> serializedSources = src .trackSources() .stream() .map(src::getState) .map(s -> { final JsonObject typeAndData = new JsonObject(); typeAndData.addProperty(STATE_TYPE_KEY, s.getClass().getName()); typeAndData.add(STATE_KEY, context.serialize(s, s.getClass())); return typeAndData; }) .collect(Collectors.toList()); LOG.debug("Serialized sources: {}", serializedSources); final int currentSourceIndex = src.currentSourceIndexProperty().get(); elements.put(NUM_SOURCES_KEY, sources.size()); elements.put(CURRENT_SOURCE_INDEX_KEY, currentSourceIndex); elements.put(SOURCES_KEY, serializedSources); return context.serialize(elements); }
Example 4
Source File: AffineSerializer.java From paintera with GNU General Public License v2.0 | 5 votes |
@Override public JsonElement serialize(Affine a, Type typeOfSrc, JsonSerializationContext context) { return context.serialize(new double[] { a.getMxx(), a.getMxy(), a.getMxz(), a.getTx(), a.getMyx(), a.getMyy(), a.getMyz(), a.getTy(), a.getMzx(), a.getMzy(), a.getMzz(), a.getTz() }); }
Example 5
Source File: MeshNetworkDeserializer.java From Android-nRF-Mesh-Library with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Returns serialized json element containing the allocated group ranges * * @param context Serializer context * @param ranges allocated group range */ private JsonElement serializeAllocatedGroupRanges(@NonNull final JsonSerializationContext context, @NonNull final List<AllocatedGroupRange> ranges) { final Type allocatedGroupRanges = new TypeToken<List<AllocatedGroupRange>>() { }.getType(); return context.serialize(ranges, allocatedGroupRanges); }
Example 6
Source File: LogicalExpression.java From influxdb-client-java with MIT License | 4 votes |
@Override public JsonElement serialize(Object object, Type typeOfSrc, JsonSerializationContext context) { return context.serialize(object); }
Example 7
Source File: PkgSummaryDiffVariables.java From influxdb-client-java with MIT License | 4 votes |
@Override public JsonElement serialize(Object object, Type typeOfSrc, JsonSerializationContext context) { return context.serialize(object); }
Example 8
Source File: Property.java From influxdb-client-java with MIT License | 4 votes |
@Override public JsonElement serialize(Object object, Type typeOfSrc, JsonSerializationContext context) { return context.serialize(object); }
Example 9
Source File: View.java From influxdb-client-java with MIT License | 4 votes |
@Override public JsonElement serialize(Object object, Type typeOfSrc, JsonSerializationContext context) { return context.serialize(object); }
Example 10
Source File: LogicalExpression.java From influxdb-client-java with MIT License | 4 votes |
@Override public JsonElement serialize(Object object, Type typeOfSrc, JsonSerializationContext context) { return context.serialize(object); }
Example 11
Source File: UnaryExpression.java From influxdb-client-java with MIT License | 4 votes |
@Override public JsonElement serialize(Object object, Type typeOfSrc, JsonSerializationContext context) { return context.serialize(object); }
Example 12
Source File: ConditionalExpression.java From influxdb-client-java with MIT License | 4 votes |
@Override public JsonElement serialize(Object object, Type typeOfSrc, JsonSerializationContext context) { return context.serialize(object); }
Example 13
Source File: ConditionalExpression.java From influxdb-client-java with MIT License | 4 votes |
@Override public JsonElement serialize(Object object, Type typeOfSrc, JsonSerializationContext context) { return context.serialize(object); }
Example 14
Source File: Variable.java From influxdb-client-java with MIT License | 4 votes |
@Override public JsonElement serialize(Object object, Type typeOfSrc, JsonSerializationContext context) { return context.serialize(object); }
Example 15
Source File: ReturnStatement.java From influxdb-client-java with MIT License | 4 votes |
@Override public JsonElement serialize(Object object, Type typeOfSrc, JsonSerializationContext context) { return context.serialize(object); }
Example 16
Source File: IndexExpression.java From influxdb-client-java with MIT License | 4 votes |
@Override public JsonElement serialize(Object object, Type typeOfSrc, JsonSerializationContext context) { return context.serialize(object); }
Example 17
Source File: BinaryExpression.java From influxdb-client-java with MIT License | 4 votes |
@Override public JsonElement serialize(Object object, Type typeOfSrc, JsonSerializationContext context) { return context.serialize(object); }
Example 18
Source File: MeshNetworkDeserializer.java From Android-nRF-Mesh-Library with BSD 3-Clause "New" or "Revised" License | 3 votes |
/** * Returns a JsonElement of application keys keys after serializing the network keys * * @param context Serializer context * @param networkKeys Network key list * @return JsonElement */ private JsonElement serializeNetKeys(@NonNull final JsonSerializationContext context, @NonNull final List<NetworkKey> networkKeys) { final Type networkKey = new TypeToken<List<NetworkKey>>() { }.getType(); return context.serialize(networkKeys, networkKey); }
Example 19
Source File: MeshNetworkDeserializer.java From Android-nRF-Mesh-Library with BSD 3-Clause "New" or "Revised" License | 3 votes |
/** * Returns a list of network keys after serializing application keys list * * @param context Serializer context * @param applicationKeys Application key list * @return JsonElement */ private JsonElement serializeAppKeys(@NonNull final JsonSerializationContext context, @NonNull final List<ApplicationKey> applicationKeys) { final Type networkKey = new TypeToken<List<ApplicationKey>>() { }.getType(); return context.serialize(applicationKeys, networkKey); }
Example 20
Source File: InternalElementListDeserializer.java From Android-nRF-Mesh-Library with BSD 3-Clause "New" or "Revised" License | 2 votes |
/** * Returns serialized json element containing the mesh models * * @param context Serializer context * @param meshModels models map * @return JsonElement */ private JsonElement serializeModels(final JsonSerializationContext context, final Map<Integer, MeshModel> meshModels) { final Type meshModelList = new TypeToken<List<MeshModel>>() { }.getType(); return context.serialize(populateModels(meshModels), meshModelList); }