Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package org.astri.isns.elderly;
- import com.google.gson.JsonElement;
- import com.google.gson.JsonSerializationContext;
- import com.google.gson.JsonSerializer;
- import java.lang.reflect.Type;
- import java.util.Map;
- import io.skygear.skygear.Record;
- /**
- * Created by funglam on 2/21/17.
- */
- public class RecordSerializer implements JsonSerializer<Record> {
- public JsonElement serialize(Record src, Type typeOfSrc, JsonSerializationContext context) {
- Map<String, Object> root = src.getData();
- Map<String, Object> firstLevel = src.getTransient();
- for (String key : firstLevel.keySet()) {
- Record r = (Record) firstLevel.get(key);
- root.put(key, r.getData());
- }
- return context.serialize(root);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement