Can not deserialize instance of out of START_ARRAY token
阿新 • • 發佈:2019-01-10
Can not deserialize instance of com.entity.StudentDto out of START_ARRAY token
at [Source: org.glassfish.jersey.me[email protected]5aa0b86d; line: 1, column: 1]
專案背景:jersey框架,fastjson
<!-- 加入fastjson依賴包 --> <dependency> <groupId>com.alibaba</groupId> <artifactId>fastjson</artifactId> <version>1.1.37</version> </dependency>
1:對於json為String用{}包裹 中存在單個[{}]物件的,單獨定義class用List定義接收
2: 存在陣列的,定義欄位為String[ ]接收;private String[] probeTemperatures;
3:類定義
* @note 接收的json的引數類
* @author alex
* @date 2018年4月19日
*/
@Data
public class VehInfoDto {
private String id;
private String reportDataId;
private String vin;
private String eventId;
private String messageType;
private int sequence;
private String eventDateTimeUTC;
private String createdDate;
private String lastUpdatedDate;
private CompleteVehicle completeVehicle;
private Engine engine;
private FuelCell fuelCell;
private Gps gps;
private LimitValue limitValue;
private Warnings warnings;
private List<ElectricalMachine> electricalMachine;//此class必須List
}
ps:今天天氣不錯,就開心把出問題並解決的json貼出來
{"id":"5a5f0328548e3b6515fd530a","reportDataId":"98038e7a-a93f-4ade-9865-d2ab575485d1","vin":"WL42110","eventId":"[email protected]","messageType":"REAL_TIME_DATA_REPORTING","sequence":250,"eventDateTimeUTC":"2020-02-23T12:07:23.000+0000","engine":{"state":"ON","crankshaftSpeed":4000,"fuelConsumption":400},"completeVehicle":{"vehicleState":"STARTUP","chargingState":"UNCHARGED","operationMode":"FUEL","vehicleSpeed":110,"accumulatedMilage":1234567,"totalVoltage":1000,"totalCurrent":500,"soc":55,"dcdcState":"STANDBY","gearPosition":{"type":"GEAR_3","drivingForce":false,"brakingForce":false},"insulationResistance":45679},"electricalMachine":[{"sn":1,"state":"DEACTIVATION_STATE","controllerTemperature":25,"speed":0,"torque":0,"temperature":24,"inputVoltage":3000,"controllerDcBusCurrent":10}],"fuelCell":{"voltage":299,"current":2000,"fuelConsumption":1998,"probeTemperatures":[100,101,103],"maxTempInHydrogenSystem":1000,"maxPressureOfHydrogen":500,"maxConcentrationOfHydrogen":34000,"codeOfProbeWithMaxTempInHydrogenSystem":4,"codeOfSensorWithMaxConcentrationOfHydrogen":2,"codeOfSensorWithMaxPressureOfHydrogen":1,"highPreasureDcdcState":"STANDBY"},"gps":{"positioningType":"TRANSFORMED","northLatitude":true,"eastLongitude":true,"transformationType":"THIRD_PARTY","longitude":0.027777777777777776,"latitude":0.027777777777777776},"limitValue":{"idNoOfBatterySubsystemWithMinVoltage":2,"idNoOfBatterySubsystemWithMaxVoltage":1,"idNoOfCellWithMinVoltage":2,"idNoOfCellWithMaxVoltage":4,"idNoOfSubsystemWithMinTemperature":1,"idNoOfSubsystemWithMaxTemperature":1,"codeOfProbeSubsystemWithMinTemperature":2,"codeOfSingleProbeWithMaxTemperature":1,"minTemperature":66,"maxTemperature":60},"warnings":{"highestWarningLevel":"LEVEL_2_FAULT","warnings":[{"faultType":"ELECTRICAL_MACHINE_FAULT","deviceId":2,"faultCode":66,"warningLevel":"LEVEL_2_FAULT","warningMark":"TEMPERATURE_DIFFERENCE"},{"faultType":"ELECTRICAL_MACHINE_FAULT","deviceId":1,"faultCode":66,"warningLevel":"LEVEL_2_FAULT","warningMark":"TEMPERATURE_DIFFERENCE"}]},"createdDate":"2018-01-17T08:02:48.787+0000","lastUpdatedDate":"2018-01-17T08:02:49.072+0000"}