#AndroidStudio插件之GsonOrXmlFormat**GsonOrXmlFormat**[下载链接](https://plugins.jetbrains.com/plugin/8435?pr=)首先,谈谈开发这个插件的原因。在做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**[描述](https://plugins.jetbrains.com/plugin/7654?pr=)**基于GsonFormat 集成了xml格式一>bean类**如何使用该插件呢**1.接下是安装插件,然后restart。**>>**2.使用插件,在弄的里面,点击右键Generate->GsonOrXmlFormat**>>>>把xml报文黏贴进去如下图:>**3.效果**>>**生成的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;}}}}```
网友评论