NostrFilter.fromJson constructor

NostrFilter.fromJson(
  1. Map<String, dynamic> json
)

Deserialize aNpstrFilter from a JSON

Implementation

factory NostrFilter.fromJson(Map<String, dynamic> json) {
  final ids =
      json['ids'] == null ? null : List<String>.from(json['ids'] as List);

  final authors = json['authors'] == null
      ? null
      : List<String>.from(json['authors'] as List);

  final kinds =
      json['kinds'] == null ? null : List<int>.from(json['kinds'] as List);

  final e = json['#e'] == null ? null : List<String>.from(json['#e'] as List);

  final p = json['#p'] == null ? null : List<String>.from(json['#p'] as List);

  final t = json['#t'] == null ? null : List<String>.from(json['#t'] as List);

  final a = json['#a'] == null ? null : List<String>.from(json['#a'] as List);
  final since =
      DateTime.fromMillisecondsSinceEpoch((json['since'] as int) * 1000);

  final until =
      DateTime.fromMillisecondsSinceEpoch((json['until'] as int) * 1000);

  final limit = json['limit'] as int?;

  final search = json['search'] as String?;

  return NostrFilter(
    ids: ids,
    authors: authors,
    kinds: kinds,
    e: e,
    p: p,
    t: t,
    a: a,
    since: since,
    until: until,
    limit: limit,
    search: search,
  );
}