Last active
February 21, 2017 09:30
-
-
Save seventhmoon/32945853a68f2a5451b3d638ccf7781b to your computer and use it in GitHub Desktop.
Gson Serializer for Skygear Record
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | |
root.putAll(firstLevel); | |
return context.serialize(root); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment