Back to project page kluster-android.
The source code is released under:
Apache License
If you think the Android project kluster-android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.cs446.kluster.data.serialize; // ww w . jav a2s . c o m import java.io.IOException; import com.cs446.kluster.models.User; import com.google.gson.TypeAdapter; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonToken; import com.google.gson.stream.JsonWriter; public class UserAdapter extends TypeAdapter<User> { public User read(JsonReader reader) throws IOException { if (reader.peek() == JsonToken.NULL) { reader.nextNull(); return null; } return null; } public void write(JsonWriter writer, User value) throws IOException { if (value == null) { writer.nullValue(); return; } writer.beginObject(); writer.name("username"); writer.value(value.getUserName()); writer.name("email"); writer.value(value.getUserEmail()); writer.name("password"); writer.value(value.getPassword()); writer.name("name"); writer.beginObject(); writer.name("first"); writer.value(value.getFirstName()); writer.name("last"); writer.value(value.getLastName()); writer.endObject(); writer.endObject(); } }