Advertisement
Guest User

Untitled

a guest
Feb 20th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. package org.astri.isns.elderly;
  2.  
  3. import com.google.gson.JsonElement;
  4. import com.google.gson.JsonSerializationContext;
  5. import com.google.gson.JsonSerializer;
  6.  
  7. import java.lang.reflect.Type;
  8. import java.util.Map;
  9.  
  10. import io.skygear.skygear.Record;
  11.  
  12. /**
  13. * Created by funglam on 2/21/17.
  14. */
  15.  
  16. public class RecordSerializer implements JsonSerializer<Record> {
  17.  
  18.  
  19. public JsonElement serialize(Record src, Type typeOfSrc, JsonSerializationContext context) {
  20. Map<String, Object> root = src.getData();
  21. Map<String, Object> firstLevel = src.getTransient();
  22.  
  23. for (String key : firstLevel.keySet()) {
  24. Record r = (Record) firstLevel.get(key);
  25. root.put(key, r.getData());
  26. }
  27.  
  28. return context.serialize(root);
  29.  
  30. }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement