1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | public class Main { public static void main(String[] args) throws IOException { AS as = JSON.parseObject("{\"array\":[{\"str\":\"hello\"},{\"str\":\"world\"}]}", AS.class); System.out.println(as.array == null); if(as.array != null){ System.out.println(as.array.length); for(ASs a : as.array) System.out.println(a.str); } } private static class ASs{ @JSONField(name = "str") public String str; } private static class AS{ @JSONField( name = "array") public ASs[] array; } } |
Direct link: https://paste.plurk.com/show/NbuEdPGHIv2e5hfdfSJy