lexicon 0.2.2 copy "lexicon: ^0.2.2" to clipboard
lexicon: ^0.2.2 copied to clipboard

Core library for parsing Lexicon in the AT Protocol standard.

example/example.dart

// Copyright 2023 Shinya Kato. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided the conditions.

import 'package:lexicon/docs.dart' as docs;
import 'package:lexicon/lexicon.dart';

void main() {
  //* Easy to parse lexicon from JSON.
  final appBskyFeedLike = LexiconDoc.fromJson({
    'lexicon': 1,
    'id': 'app.bsky.feed.like',
    'defs': {
      'main': {
        'type': 'record',
        'description': 'A declaration of a like.',
        'key': 'tid',
        'record': {
          'type': 'object',
          'required': ['subject', 'createdAt'],
          'properties': {
            'subject': {'type': 'ref', 'ref': 'com.atproto.repo.strongRef'},
            'createdAt': {'type': 'string', 'format': 'datetime'}
          }
        }
      }
    }
  });

  print(appBskyFeedLike.id);
  print(appBskyFeedLike.description);
  print(appBskyFeedLike.defs);

  //* Or you can use prepared official lexicons.
  final appBskyFeedPost = LexiconDoc.fromJson(docs.appBskyFeedPost);
  print(appBskyFeedPost);

  //* Also you can see all official lexicons.
  for (final lexicon in docs.lexicons) {
    final lexiconDoc = LexiconDoc.fromJson(lexicon);

    print(lexiconDoc.id);
    print(lexiconDoc.description);
    print(lexiconDoc.defs);
  }
}
1
likes
150
pub points
21%
popularity

Publisher

verified publisheratprotodart.com

Core library for parsing Lexicon in the AT Protocol standard.

Homepage
Repository (GitHub)
View/report issues

Documentation

API reference

Funding

Consider supporting this project:

github.com

License

BSD-3-Clause (license)

Dependencies

freezed_annotation, json_annotation, nsid

More

Packages that depend on lexicon