json2apex
json2apex copied to clipboard
InnerClasses/Arrays unconventionally named.
When the JSON contains an array/list the naming is rather unconventional with regard plurals.
Given the following Json
{"accountId":"EX1-234-567890","description":"Unit Test JSON","refPeriod": "2019-02-01","actionDate":"2019-03-31","lines":[
{"productId":"b2c-01","description":"service","qty":"1","unitPrice":"2.00"},
{"productId":"b2b-01","description":"devices","qty":"2","unitPrice":"2.00"},
{"productId":"b2x-01","description":"overage","qty":"3","unitPrice":"2.00"}]}
Actual Behaviour: The following code is generated.
`public class JSON2Apex {
public String accountId;
public String description;
public String refPeriod;
public String actionDate;
public List<Lines> lines;
public class Lines {
public String productId;
public String description;
public String qty;
public String unitPrice;
}
public static JSON2Apex parse(String json) {
return (JSON2Apex) System.JSON.deserialize(json, JSON2Apex.class);
}
}`
The inner class is plural. Conventionally the inner class should be Line and the list instance lines. I would expect the following code to be generated, with the relevant difference in bold.
`public class JSON2Apex {
public String accountId;
public String description;
public String refPeriod;
public String actionDate;
**public List<Line> lines;**
**public class Line** {
public String productId;
public String description;
public String qty;
public String unitPrice;
}
`