dart-json-mapper
dart-json-mapper copied to clipboard
Cannot map uppercase int´s or doubles
I am using dart_json_mapper: ^2.2.9 and have been using it without problems for many of my models for a long time :)
I am now experiencing a problem where I cannot parse json data from network on uppercased int´s or doubles.
This is my condensed classes:
@JsonSerializable()
@Json(caseStyle: CaseStyle.pascal, ignoreNullMembers: true)
class DTDeviceStatus {
String? deviceIdent;
List<DTGatewayConnection> gatewayConnections = [];
}
@JsonSerializable()
@Json(caseStyle: CaseStyle.pascal, ignoreNullMembers: true)
class DTGatewayConnection {
String gwIdent = '';
DTSignalStrength? signalStrength;
}
@JsonSerializable()
@Json(ignoreNullMembers: true)
class DTSignalStrength {
@JsonProperty(name: 'Strength')
ESignalStrength strength = ESignalStrength.NoSignal;
@JsonProperty(name: 'RSSI')
int? rssi;
@JsonProperty(name: 'SpreadFactor')
int? spreadFactor;
}
The problem is that rssi is null. The spreadFactor int and the strength enum is correctly converted.
I usually deserialise my classes from network like this:
List<DTDeviceStatus> devices = JsonMapper.deserialize<List<DTDeviceStatus>>(response.data['Devices']) ?? [];
This is the json I receive (response.data.toString():):
"{Devices: [{DeviceIdent: 94949494, GatewayConnections: [{GwIdent: 39847384, SignalStrength: {Strength: Strong, RSSI: -74, SNR: 0.0, SpreadFactor: 5}]}"
When I directly convert and print, I get:
print(device.gatewayConnections[0].signalStrength?.strength); //Strong
print(device.gatewayConnections[0].signalStrength?.rssi); //null
Am I missing something here? Thanks :)