Replace own implementation of toJson with gson.