package ;
public class Delivery {
private String code;
private String status;
public void setCode(String code){
this.code = code;
}
public String getCode(){
return this.code;
}
public void setStatus(String status){
this.status = status;
}
public String getStatus(){
return this.status;
}
package ;
public class Origin {
private String value;
private String label;
private String url;
public void setValue(String value){
this.value = value;
}
public String getValue(){
return this.value;
}
public void setLabel(String label){
this.label = label;
}
public String getLabel(){
return this.label;
}
public void setUrl(String url){
this.url = url;
}
public String getUrl(){
return this.url;
}
package ;
public class Destination {
private String value;
private String label;
private String url;
public void setValue(String value){
this.value = value;
}
public String getValue(){
return this.value;
}
public void setLabel(String label){
this.label = label;
}
public String getLabel(){
return this.label;
}
public void setUrl(String url){
this.url = url;
}
public String getUrl(){
return this.url;
}
package ;
public class Link {
private String url;
private String label;
public void setUrl(String url){
this.url = url;
}
public String getUrl(){
return this.url;
}
public void setLabel(String label){
this.label = label;
}
public String getLabel(){
return this.label;
}
package ;
public class Signature {
private Link link;
private String type;
private String description;
private String signatory;
private String label;
private String help;
public void setLink(Link link){
this.link = link;
}
public Link getLink(){
return this.link;
}
public void setType(String type){
this.type = type;
}
public String getType(){
return this.type;
}
public void setDescription(String description){
this.description = description;
}
public String getDescription(){
return this.description;
}
public void setSignatory(String signatory){
this.signatory = signatory;
}
public String getSignatory(){
return this.signatory;
}
public void setLabel(String label){
this.label = label;
}
public String getLabel(){
return this.label;
}
public void setHelp(String help){
this.help = help;
}
public String getHelp(){
return this.help;
}
package ;
public class PIds {
package ;
import java.util.List;
public class Pieces {
private int value;
private String label;
private boolean showSummary;
private List pIds ;
public void setValue(int value){
this.value = value;
}
public int getValue(){
return this.value;
}
public void setLabel(String label){
this.label = label;
}
public String getLabel(){
return this.label;
}
public void setShowSummary(boolean showSummary){
this.showSummary = showSummary;
}
public boolean getShowSummary(){
return this.showSummary;
}
public void setPIds(List pIds){
this.pIds = pIds;
}
public List getPIds(){
return this.pIds;
}
package ;
public class Checkpoints {
private int counter;
private String description;
private String time;
private String date;
private String location;
public void setCounter(int counter){
this.counter = counter;
}
public int getCounter(){
return this.counter;
}
public void setDescription(String description){
this.description = description;
}
public String getDescription(){
return this.description;
}
public void setTime(String time){
this.time = time;
}
public String getTime(){
return this.time;
}
public void setDate(String date){
this.date = date;
}
public String getDate(){
return this.date;
}
public void setLocation(String location){
this.location = location;
}
public String getLocation(){
return this.location;
}
package ;
import java.util.List;
public class Results {
private String id;
private String label;
private String type;
private boolean duplicate;
private Delivery delivery;
private Origin origin;
private Destination destination;
private String description;
private boolean hasDuplicateShipment;
private Signature signature;
private Pieces pieces;
private List checkpoints ;
private String checkpointLocationLabel;
private String checkpointTimeLabel;
public void setId(String id){
this.id = id;
}
public String getId(){
return this.id;
}
public void setLabel(String label){
this.label = label;
}
public String getLabel(){
return this.label;
}
public void setType(String type){
this.type = type;
}
public String getType(){
return this.type;
}
public void setDuplicate(boolean duplicate){
this.duplicate = duplicate;
}
public boolean getDuplicate(){
return this.duplicate;
}
public void setDelivery(Delivery delivery){
this.delivery = delivery;
}
public Delivery getDelivery(){
return this.delivery;
}
public void setOrigin(Origin origin){
this.origin = origin;
}
public Origin getOrigin(){
return this.origin;
}
public void setDestination(Destination destination){
this.destination = destination;
}
public Destination getDestination(){
return this.destination;
}
public void setDescription(String description){
this.description = description;
}
public String getDescription(){
return this.description;
}
public void setHasDuplicateShipment(boolean hasDuplicateShipment){
this.hasDuplicateShipment = hasDuplicateShipment;
}
public boolean getHasDuplicateShipment(){
return this.hasDuplicateShipment;
}
public void setSignature(Signature signature){
this.signature = signature;
}
public Signature getSignature(){
return this.signature;
}
public void setPieces(Pieces pieces){
this.pieces = pieces;
}
public Pieces getPieces(){
return this.pieces;
}
public void setCheckpoints(List checkpoints){
this.checkpoints = checkpoints;
}
public List getCheckpoints(){
return this.checkpoints;
}
public void setCheckpointLocationLabel(String checkpointLocationLabel){
this.checkpointLocationLabel = checkpointLocationLabel;
}
public String getCheckpointLocationLabel(){
return this.checkpointLocationLabel;
}
public void setCheckpointTimeLabel(String checkpointTimeLabel){
this.checkpointTimeLabel = checkpointTimeLabel;
}
public String getCheckpointTimeLabel(){
return this.checkpointTimeLabel;
}
package ;
import java.util.List;
public class Root {
private List results ;
public void setResults(List results){
this.results = results;
}
public List getResults(){
return this.results;
}
}
解析的时候使用Gson的jar包
Gson gson = new Gson();
Result result = gson.fromJson(result,Result.class);
最后给你几个json转java文件的链接:
http://www.bejson.com/json2javapojo/
http://www.jsonschema2pojo.org/
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。