56 lines
1.4 KiB
Dart
56 lines
1.4 KiB
Dart
// To parse this JSON data, do
|
|
//
|
|
// final publications = publicationsFromJson(jsonString);
|
|
|
|
import 'dart:convert';
|
|
|
|
List<Publications> publicationsFromJson(String str) => List<Publications>.from(
|
|
json.decode(str).map((x) => Publications.fromJson(x)));
|
|
|
|
String publicationsToJson(List<Publications> data) =>
|
|
json.encode(List<dynamic>.from(data.map((x) => x.toJson())));
|
|
|
|
class Publications {
|
|
int id;
|
|
int userId;
|
|
String articalTitle;
|
|
String journalName;
|
|
DateTime date;
|
|
String author;
|
|
dynamic createdAt;
|
|
dynamic updatedAt;
|
|
|
|
Publications({
|
|
required this.id,
|
|
required this.userId,
|
|
required this.articalTitle,
|
|
required this.journalName,
|
|
required this.date,
|
|
required this.author,
|
|
required this.createdAt,
|
|
required this.updatedAt,
|
|
});
|
|
|
|
factory Publications.fromJson(Map<String, dynamic> json) => Publications(
|
|
id: json["id"],
|
|
userId: json["user_id"],
|
|
articalTitle: json["artical_title"],
|
|
journalName: json["journal_name"],
|
|
date: DateTime.parse(json["date"]),
|
|
author: json["author"],
|
|
createdAt: json["created_at"],
|
|
updatedAt: json["updated_at"],
|
|
);
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
"id": id,
|
|
"user_id": userId,
|
|
"artical_title": articalTitle,
|
|
"journal_name": journalName,
|
|
"date": date.toIso8601String(),
|
|
"author": author,
|
|
"created_at": createdAt,
|
|
"updated_at": updatedAt,
|
|
};
|
|
}
|