5. JSON Data Types
String "name": "Andy"
Boolean “hasMoney": false
int “age": 26
float “height”: 176.1
6. JSON Object Parser
JSONObject jsonObject = new JSONObject(json);
JSONArray jsonArray = new JSONArray(json);
for (int i = 0;sizeOfJSON; i++) {
jsonObject.get("key");
jsonArray.get(i);
………
}
7. How about GSON
Model First
public class Employees {
@SerializedName("firstName") String firstName;
@SerializedName("firstName") String lastName;
geter
setter
….
}
9. GSON Collection Parser
Gson gson = new Gson();
Type type = new
TypeToken<List<Employees>>(){}.getType();
List<Employees> employees
= gson.fromJson(json, type);
10. Powerful Paser
Date fotmat parser
Gson gson = new
GsonBuilder().setDateFormat("yyyy/MM/dd
HH:mm:ss”).create();