我正在尝试解析一个看起来像这样的 yaml 文件(它是动态的,所以这只是一个例子):size: 4533vehicles: '1': vecUUID: fa461669-6b88-418d-8e7c-219e784a21fc ownerUUID: da36067f-7af8-411b-b820-8e0709b4d64e invString: | rO0ABXcEAAAACXBwcHBwcHBwcA== '2': vecUUID: 3c192337-c9dd-45f0-92c0-545d42d5404d ownerUUID: da36067f-7af8-411b-b820-8e0709b4d64e invString: | rO0ABXcEAAAACXBwcHBwcHBwcA== '3': vecUUID: d5df362b-c4f8-4d82-9e3a-c37fba1162f0 ownerUUID: fd44ce79-32b5-4080-9953-3d0f4d5399b1 invString: | rO0ABXcEAAAAEnBwcHBwcHBwc3IAGm9yZy5idWtraXQudXRpbC5pby5XcmFwcGVy8lBH7PESbwUC AAFMAANtYXB0AA9MamF2YS91dGlsL01hcDt4cHNyADVjb20uZ29vZ2xlLmNvbW1vbi5jb2xsZWN0 LkltbXV0YWJsZU1hcCRTZXJpYWxpemVkRm9ybQAAAAAAAAAAAgACWwAEa2V5c3QAE1tMamF2YS9s YW5nL09iamVjdDtbAAZ2YWx1ZXNxAH4ABHhwdXIAE1tMamF2YS5sYW5nLk9iamVjdDuQzlifEHMp bAIAAHhwAAAAA3QAAj09dAAEdHlwZXQABmFtb3VudHVxAH4ABgAAAAN0AB5vcmcuYnVra2l0Lmlu dmVudG9yeS5JdGVtU3RhY2t0AAxHTEFTU19CT1RUTEVzcgARamF2YS5sYW5nLkludGVnZXIS4qCk 94GHOAIAAUkABXZhbHVleHIAEGphdmEubGFuZy5OdW1iZXKGrJUdC5TgiwIAAHhwAAAADHBwcHBw cHBwcA==我创建了 3 个类,Vehicle、VehicleInfo 和 MyYamlFile,如下所示。车辆public class Vehicle { @JsonProperty private List<VehicleInfo> info; // getter methods ommitted}车辆信息public class VehicleInfo { @JsonProperty private String vecUUID; @JsonProperty private String ownerUUID; @JsonProperty private String invString; // getter methods ommitted }我的Yaml文件public class MyYamlFile { @JsonProperty private List<Vehicle> vehicles; @JsonProperty private int size; // getter methods ommitted}问题是当我运行它时,如下所示:public class Fix { public static void main(String[] args) { MyYamlFile file = readYaml(new File("E:\\dev\\FrihedenBilInventoryFix\\VehicleInventory.yaml")); System.out.print("test: " + file.getSize()); }我收到一个错误com.fasterxml.jackson.databind.exc.MismatchedInputException:无法从 START_OBJECT 令牌中反序列化 java.util.ArrayList 的实例 [来源:(文件);行:3,列:3](通过参考链:MyYamlFile["vehicles"])知道为什么吗?
添加回答
举报
0/150
提交
取消