Ahmed-Ali / JSONExport

JSONExport is a desktop application for Mac OS X which enables you to export JSON objects as model classes with their associated constructors, utility methods, setters and getters in your favorite language.
Other
4.79k stars 794 forks source link

Java Gson for Android: Fix method name #108

Closed ty0521-fss closed 5 years ago

ty0521-fss commented 6 years ago

Java Gson for Android

Fix method name to be "optString" instead of "opt" to get String type value from JSONObject in constructor.

private String title;
title = jsonObject.opt("title"); // Error: Incompatible types.

private String title;
title = jsonObject.optString("title");


Fix: float type issue

private float latitude;
latitude = jsonObject.optFloat("latitude"); // optFloat not exist

private float latitude;
latitude = (float) jsonObject.optDouble("latitude");