This repository was archived by the owner on Oct 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
non_static_inner_class_support_cn
高铁 edited this page Mar 25, 2017
·
1 revision
public class Model {
public static class Item {
}
}
public class Model {
public class Item {
}
}
非静态内嵌类,编译之后,构造函数的参数是外层的类。在上面的例子中,Item的构造函数是:
Item (Model modelThis) {}
这样是的在反序列化时,构造内嵌类实例产生了一些麻烦,必须传入Model的实例。
public class Model {
public Item item;
public class Item {
}
}
Model model = JSON.parseObject("{\"item\":{}}", Model.class);
public class Model {
public List<Item> items;
public class Item {
}
}
Model model = JSON.parseObject("{\"items\":[{}]}", Model.class);
public class Model {
public Map<String, Item> items;
public class Item {
}
}
Model model = JSON.parseObject("{\"items\":{\"123\":{}}}", Model.class);
如有需要修改本注脚,请联系阿里巴巴,
© Alibaba Fastjson Develop Team
注明: 版权所有阿里巴巴,请注明版权所有者
If you need to amend this footnote, please contact Alibaba.
© Alibaba Fastjson Develop Team
Note: Copyright Alibaba, please indicate the copyright owner