We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No description provided.
The text was updated successfully, but these errors were encountered:
@nbali would you like to contribute a PR?
Sorry, something went wrong.
I have no time to do it properly with docs, tests and stuff nowadays, but here is the pure code itself for anyone willing to finish it:
import java.lang.reflect.Type; import java.time.YearMonth; import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonDeserializer; import com.google.gson.JsonElement; import com.google.gson.JsonParseException; import com.google.gson.JsonPrimitive; import com.google.gson.JsonSerializationContext; import com.google.gson.JsonSerializer; import com.google.gson.reflect.TypeToken;
...
private static class YearMonthConverter implements JsonSerializer<YearMonth>, JsonDeserializer<YearMonth> { private static final Type TYPE = TypeToken.get(YearMonth.class).getType(); @Override public JsonElement serialize(YearMonth src, Type typeOfSrc, JsonSerializationContext context) { return new JsonPrimitive(src.toString()); } @Override public YearMonth deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { return YearMonth.parse(json.getAsString()); } }
No branches or pull requests
No description provided.
The text was updated successfully, but these errors were encountered: