64 lines
1.6 KiB
Dart
64 lines
1.6 KiB
Dart
// To parse this JSON data, do
|
|
//
|
|
// final jwtDecodedData = jwtDecodedDataFromJson(jsonString);
|
|
|
|
import 'dart:convert';
|
|
|
|
JwtDecodedData jwtDecodedDataFromJson(String str) =>
|
|
JwtDecodedData.fromJson(json.decode(str));
|
|
|
|
String jwtDecodedDataToJson(JwtDecodedData data) => json.encode(data.toJson());
|
|
|
|
class JwtDecodedData {
|
|
String? authType;
|
|
String? deviceCode;
|
|
int? deviceId;
|
|
String? deviceRole;
|
|
String? eventName;
|
|
String? oId;
|
|
List<String>? oIds;
|
|
String? organizerId;
|
|
|
|
JwtDecodedData({
|
|
this.authType,
|
|
this.deviceCode,
|
|
this.deviceId,
|
|
this.deviceRole,
|
|
this.eventName,
|
|
this.oId,
|
|
this.oIds,
|
|
this.organizerId,
|
|
});
|
|
|
|
factory JwtDecodedData.fromJson(Map<String, dynamic> json) => JwtDecodedData(
|
|
authType: json['authType']?.toString(),
|
|
deviceCode: json['deviceCode']?.toString(),
|
|
deviceId: _readInt(json['deviceId']),
|
|
deviceRole: json['deviceRole']?.toString(),
|
|
eventName: json['eventName']?.toString(),
|
|
oId: json['oId']?.toString(),
|
|
oIds: json['oIds'] == null
|
|
? []
|
|
: List<String>.from(json['oIds']!.map((x) => x?.toString())),
|
|
organizerId: json['organizerId']?.toString(),
|
|
);
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
'authType': authType,
|
|
'deviceCode': deviceCode,
|
|
'deviceId': deviceId,
|
|
'deviceRole': deviceRole,
|
|
'eventName': eventName,
|
|
'oId': oId,
|
|
'oIds': oIds == null ? [] : List<dynamic>.from(oIds!.map((x) => x)),
|
|
'organizerId': organizerId,
|
|
};
|
|
}
|
|
|
|
int? _readInt(dynamic value) {
|
|
if (value == null) return null;
|
|
if (value is int) return value;
|
|
if (value is num) return value.toInt();
|
|
return int.tryParse(value.toString());
|
|
}
|