不管怎麼說,這東西感覺還挺好用的
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;
}
}
輸出長這樣
.
字串遇到 File 也會自動轉換
雖然會去搞這東西也只是為了去寫一款 Minecraft 插件出來