AndroidStudio插件之GsonOrXmlFormat(
2016-06-28 本文已影响3041人
小美Y
AndroidStudio插件之GsonOrXmlFormat
GsonOrXmlFormat下载链接
首先,谈谈开发这个插件的原因。在做android 客户端获取服务器数据,采用当下流行json格式,但是也有很多还残留着xml字符串格式,对于后台返回的xml/json的字符串不得不自己手动编写json/xml格式->bean 类。这个过程是枯燥而且乏味,有时候还容易出错,所以希望GsonOrXmlFormat帮你完成json/xml ->bean类的生成(quickly to convert a JSON string or XML string to an entity class)。提高开发效率.
首先要感谢dim轻微的GsonFormat描述
基于GsonFormat 集成了xml格式一>bean类
如何使用该插件呢
1.接下是安装插件,然后restart。
![YY2WY_CC7$V8K2N]DZR5QV.jpg](http:https://img.haomeiwen.com/i1965893/7666ed35d739ac19.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
KR647D7O_KF~ZZH@V}7X63.jpg2.使用插件,在类的里面,点击右键Generate->GsonOrXmlFormat
![VL5FL3NOIJB`CET7Q38G]B.jpg](http:https://img.haomeiwen.com/i1965893/de0e80b395bc2112.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
IUEG4MXC5G6DZ$1H@{NS.png11.png把xml报文黏贴进去如下图:
3.效果
abd.gif _AH@7O2YD~}OI55B}Q.jpg生成的bean类如下
public class Test {
/**
* employee : {"sex":"m","name":"ddviplinux","age":30}
*/
private EmployeesBean employees;
public EmployeesBean getEmployees() {
return employees;
}
public void setEmployees(EmployeesBean employees) {
this.employees = employees;
}
public static class EmployeesBean {
/**
* sex : m
* name : ddviplinux
* age : 30
*/
private EmployeeBean employee;
public EmployeeBean getEmployee() {
return employee;
}
public void setEmployee(EmployeeBean employee) {
this.employee = employee;
}
public static class EmployeeBean {
private String sex;
private String name;
private int age;
public String getSex() {
return sex;
}
public void setSex(String sex) {
this.sex = sex;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
}
}
}
同理json->bean类,也是如此呀~O(∩_∩)O哈哈