Code example for Gson

Methods: toJson

0
		systemDataModel.setFreeMemory(20);
		systemDataModel.setCpuUsedPercentage(20);
		List<SystemDataModel> lists = Lists.newArrayList();
		lists.add(systemDataModel);
		lists.add(systemDataModel);
		Gson gson = new Gson();
		String json = gson.toJson(lists);
		ArrayList<SystemDataModel> fromJson = gson.fromJson(json, getTypeToken());
		System.out.println(fromJson.get(0).getClass());
	} 
 
	private Type getTypeToken() {
		return new TypeToken<ArrayList<SystemDataModel>>() {
			private static final long serialVersionUID = 1L;
		}.getType(); 
	} 
}