Generates utilities to aid in serializing to/from JSON.

Overview

Dart CI

Provides Dart Build System builders for handling JSON.

json_serializable Pub Package

The core package providing Generators for JSON-specific tasks.

Import it into your pubspec dev_dependencies: section.

json_annotation Pub Package

The annotation package which has no dependencies.

Import it into your pubspec dependencies: section.

checked_yaml Pub Package

Generate more helpful exceptions when decoding YAML documents using package:json_serializable and package:yaml.

Import it into your pubspec dependencies: section.

example

An example showing how to set up and use json_serializable and json_annotation.

Comments
  • Nested Generics

    Nested Generics

    i think this his highly related to this issue

    but i have some trouble using it for my needs. I either use it wrong or it is currently not possible.

    this is an example of what i want to parse

    {
      "status": "success",
      "message": null,
      "code": 0,
      "data": {
        "timestamp": 0,
        "result": [
          {
            "id": 409,
            "active": true,
            "accessToken": "12345_abc",
          }
        ]
      }
    }
    

    and here the corresponding classes

    @JsonSerializable()
    class WsResponse<T> extends Object with _$WsResponseSerializerMixin<T> {
    
      String status;
      String message;
      int code;
      @JsonKey(fromJson: _dataFromJson, toJson: _dataToJson)
      WsData<T> data;
    
      WsResponse({this.status, this.message, this.code, this.data});
    
      factory WsResponse.fromJson(Map<String, dynamic> json) => _$WsResponseFromJson<T>(json);
    }
    

    here i have an outer "class" with status message and code that works like every ordinary class.

    @JsonSerializable()
    class WsData<T> extends Object with _$WsDataSerializerMixin<T> {
      int timestamp;
      @JsonKey(fromJson: _resultFromJson, toJson: _resultToJson)
      List<T> result;
    
      WsData({this.timestamp, this.result});
    
      factory WsData.fromJson(Map<String, dynamic> json) => _$WsDataFromJson<T>(json);
    }
    
    @JsonSerializable()
    class WsLogin extends Object with _$WsLoginSerializerMixin {
      int id;
      bool active;
    
      String accessToken;
    
      WsLogin({this.id, this.active, this.accessToken,});
    
      factory WsLogin.fromJson(Map<String, dynamic> json) => _$WsLoginFromJson(json);
    }
    

    I omitted the fromJson etc. definitions because i don't know how to express them right either (may be the part where i am wrong)

    but if i try _dataFromJson for example

    WsData<T> _dataFromJson<T>(Map<String, dynamic> input) {
      return input['data'] as WsData<T>;
    }
    

    i get an error with

    [SEVERE] json_serializable on lib/webservice/webservice.dart:
    Error running JsonSerializableGenerator
    Error with `@JsonKey` on `data`. The `fromJson` function `_dataFromJson` return type `WsData<T>` is not compatible with field type `WsData<T>`.
    package:crewlove/webservice/webservice.dart:31:13
      WsData<T> data;
                ^^^^
    

    which is surprising for me at first. Omitting the @JsonKey annotations does not help either as i think its necessary for generics. But i don't know how to express my intent here.

    My intent is to use it like this

    var wsLoginResp = new WsResponse<WsLogin>.fromJson(json.decode(resp));  
    
    opened by pythoneer 29
  • Failed to recognize `json_annotation` from packages after 6.0.0

    Failed to recognize `json_annotation` from packages after 6.0.0

    Summary

    Use json_annotation in a package with export is no longer valid after json_serializable 6.0.0 since the build_runner will complain the error:

    You are missing a required dependency on json_annotation in the "dependencies" section of your pubspec with a lower bound of at least "4.3.0".
    

    Step to reproduce

    1. Clone the project https://github.com/AlexV525/json_annotation_test.
    2. Run build_runner build in the project_a with no issues.
    3. Change the json_serializable dependency in both package and project to 6.0.0.
    4. Change the json_annotation to 4.3.0 in the base package, but not with the project.
    5. Rerun build_runner build and the error occurred.

    Environments

    Flutter: 2.5.3

    opened by AlexV525 28
  • New Enums throws a [SEVERE] error

    New Enums throws a [SEVERE] error

    Hi,

    New flutter version 3.0.0 with dart version 2.17.0 has introduced enhanced enums. I use one of this enums for some class which gets converted into json/ from json.

    Here you can have a sample:

    enum MyExample {
      example0('example0', ExampleWidget0()),
      example1('example1', ExampleWidget1()),
      example2('example2', ExampleWidget2()),
      example3('example3', ExampleWidget3()),
      example4('example4', ExampleWidget4());
    
      const MyExample(this.value1, this.value2);
    
      final String value1;
      final Widget value2;
    
      @override
      String toString() => '$name: [$value1][$value2]';
    }
    

    Now when I run the build runner I get this error:

    [SEVERE] json_serializable:json_serializable on lib/my_example_file.dart:
    
    This builder requires Dart inputs without syntax errors.
    However, package:example/my_example_file.dart (or an existing part) contains the following errors.
    my_example_file.dart:2:11: Expected to find '}'.
    
    Try fixing the errors and re-running the build.
    

    flutter --version

    Output

    Flutter 3.0.0 • channel stable • https://github.com/flutter/flutter.git Framework • revision ee4e09cce0 (2 days ago) • 2022-05-09 16:45:18 -0700 Engine • revision d1b9a6938a Tools • Dart 2.17.0 • DevTools 2.12.2

    State: needs info 
    opened by cgutierr-zgz 27
  • NoSuchMethodError: The getter 'definingUnit' was called on null.

    NoSuchMethodError: The getter 'definingUnit' was called on null.

    Using flutter 1.22.3, when I run "flutter pub run build_runner build" I receive the following:

    [SEVERE] json_serializable:json_serializable on lib/arguments/customers_screen_arguments.dart:
    
    NoSuchMethodError: The getter 'definingUnit' was called on null.
    Receiver: null
    Tried calling: definingUnit
    #0      Object.noSuchMethod (dart:core-patch/object_patch.dart:51:5)
    #1      LinkedElementFactory.isLibraryUri (package:analyzer/src/summary2/linked_element_factory.dart:133:28)
    #2      LibraryContext.isLibraryUri (package:analyzer/src/dart/analysis/library_context.dart:97:27)
    #3      LibraryAnalyzer._isLibrarySource (package:analyzer/src/dart/analysis/library_analyzer.dart:522:25)
    #4      LibraryAnalyzer._resolveDirectives (package:analyzer/src/dart/analysis/library_analyzer.dart:562:36)
    #5      LibraryAnalyzer.analyzeSync (package:analyzer/src/dart/analysis/library_analyzer.dart:136:5)
    #6      LibraryAnalyzer.analyze (package:analyzer/src/dart/analysis/library_analyzer.dart:107:12)
    #7      AnalysisDriver._computeAnalysisResult2.<anonymous closure> (package:analyzer/src/dart/analysis/driver.dart:1317:63)
    #8      PerformanceLog.run (package:analyzer/src/dart/analysis/performance_logger.dart:32:15)
    #9      AnalysisDriver._computeAnalysisResult2 (package:analyzer/src/dart/analysis/driver.dart:1294:20)
    #10     AnalysisDriver._computeAnalysisResult.<anonymous closure> (package:analyzer/src/dart/analysis/driver.dart:1247:14)
    #11     _rootRun (dart:async/zone.dart:1190:13)
    #12     _CustomZone.run (dart:async/zone.dart:1093:19)
    #13     _runZoned (dart:async/zone.dart:1630:10)
    #14     runZoned (dart:async/zone.dart:1550:10)
    #15     NullSafetyUnderstandingFlag.enableNullSafetyTypes (package:analyzer/dart/element/null_safety_understanding_flag.dart:42:12)
    #16     AnalysisDriver._computeAnalysisResult (package:analyzer/src/dart/analysis/driver.dart:1246:40)
    #17     AnalysisDriver._computeErrors (package:analyzer/src/dart/analysis/driver.dart:1372:41)
    #18     AnalysisDriver.performWork (package:analyzer/src/dart/analysis/driver.dart:979:20)
    #19     AnalysisDriverScheduler._run (package:analyzer/src/dart/analysis/driver.dart:2013:24)
    <asynchronous suspension>
    #20     AnalysisDriverScheduler.start (package:analyzer/src/dart/analysis/driver.dart:1936:5)
    #21     analysisDriver (package:build_resolvers/src/analysis_driver.dart:62:13)
    #22     AnalyzerResolvers._ensureInitialized.<anonymous closure> (package:build_resolvers/src/resolver.dart:306:26)
    <asynchronous suspension>
    #23     AnalyzerResolvers._ensureInitialized.<anonymous closure> (package:build_resolvers/src/resolver.dart)
    #24     AnalyzerResolvers._ensureInitialized (package:build_resolvers/src/resolver.dart:309:6)
    #25     AnalyzerResolvers.get (package:build_resolvers/src/resolver.dart:314:11)
    #26     PerformanceTrackingResolvers.get.<anonymous closure> (package:build_runner_core/src/performance_tracking/performance_tracking_resolvers.dart:19:58)
    #27     _NoOpBuilderActionTracker.trackStage (package:build_runner_core/src/generate/performance_tracker.dart:302:15)
    #28     PerformanceTrackingResolvers.get (package:build_runner_core/src/performance_tracking/performance_tracking_resolvers.dart:19:16)
    #29     BuildStepImpl.resolver (package:build/src/builder/build_step_impl.dart:74:54)
    #30     _Builder.build (package:source_gen/src/builder.dart:72:32)
    #31     runBuilder.buildForInput (package:build/src/generate/run_builder.dart:55:21)
    #32     MappedListIterable.elementAt (dart:_internal/iterable.dart:417:31)
    #33     ListIterator.moveNext (dart:_internal/iterable.dart:343:26)
    #34     Future.wait (dart:async/future.dart:406:26)
    #35     runBuilder.<anonymous closure> (package:build/src/generate/run_builder.dart:61:36)
    #36     _rootRun (dart:async/zone.dart:1190:13)
    #37     _CustomZone.run (dart:async/zone.dart:1093:19)
    #38     _runZoned (dart:async/zone.dart:1630:10)
    #39     runZonedGuarded (dart:async/zone.dart:1618:12)
    #40     runZoned (dart:async/zone.dart:1547:12)
    #41     scopeLogAsync (package:build/src/builder/logging.dart:26:3)
    #42     runBuilder (package:build/src/generate/run_builder.dart:61:9)
    #43     _SingleBuild._runForInput.<anonymous closure>.<anonymous closure>.<anonymous closure> (package:build_runner_core/src/generate/build_impl.dart:485:19)
    #44     _NoOpBuilderActionTracker.trackStage (package:build_runner_core/src/generate/performance_tracker.dart:302:15)
    #45     _SingleBuild._runForInput.<anonymous closure>.<anonymous closure> (package:build_runner_core/src/generate/build_impl.dart:483:23)
    <asynchronous suspension>
    #46     _SingleBuild._runForInput.<anonymous closure>.<anonymous closure> (package:build_runner_core/src/generate/build_impl.dart)
    #47     NoOpTimeTracker.track (package:timing/src/timing.dart:222:44)
    #48     _SingleBuild._runForInput.<anonymous closure> (package:build_runner_core/src/generate/build_impl.dart:440:22)
    #49     Pool.withResource (package:pool/pool.dart:127:28)
    <asynchronous suspension>
    #50     _SingleBuild._runForInput (package:build_runner_core/src/generate/build_impl.dart:436:17)
    #51     _SingleBuild._runBuilder.<anonymous closure> (package:build_runner_core/src/generate/build_impl.dart:374:38)
    #52     MappedIterator.moveNext (dart:_internal/iterable.dart:392:20)
    #53     Future.wait (dart:async/future.dart:406:26)
    #54     _SingleBuild._runBuilder (package:build_runner_core/src/generate/build_impl.dart:373:36)
    #55     _SingleBuild._runPhases.<anonymous closure>.<anonymous closure> (package:build_runner_core/src/generate/build_impl.dart:319:20)
    <asynchronous suspension>
    #56     _SingleBuild._runPhases.<anonymous closure>.<anonymous closure> (package:build_runner_core/src/generate/build_impl.dart)
    #57     _NoOpBuildPerformanceTracker.trackBuildPhase (package:build_runner_core/src/generate/performance_tracker.dart:184:15)
    #58     _SingleBuild._runPhases.<anonymous closure> (package:build_runner_core/src/generate/build_impl.dart:315:47)
    #59     NoOpTimeTracker.track (package:timing/src/timing.dart:222:44)
    #60     _SingleBuild._runPhases (package:build_runner_core/src/generate/build_impl.dart:309:32)
    #61     logTimedAsync (package:build_runner_core/src/logging/logging.dart:25:30)
    #62     _SingleBuild._safeBuild.<anonymous closure> (package:build_runner_core/src/generate/build_impl.dart:266:26)
    #63     _rootRun (dart:async/zone.dart:1190:13)
    #64     _CustomZone.run (dart:async/zone.dart:1093:19)
    #65     _runZoned (dart:async/zone.dart:1630:10)
    #66     runZonedGuarded (dart:async/zone.dart:1618:12)
    #67     runZoned (dart:async/zone.dart:1547:12)
    #68     _SingleBuild._safeBuild (package:build_runner_core/src/generate/build_impl.dart:261:5)
    #69     _SingleBuild.run (package:build_runner_core/src/generate/build_impl.dart:208:24)
    #70     BuildImpl.run (package:build_runner_core/src/generate/build_impl.dart:94:56)
    #71     BuildRunner.run (package:build_runner_core/src/generate/build_runner.dart:25:14)
    #72     build (package:build_runner/src/generate/build.dart:107:21)
    <asynchronous suspension>
    #73     BuildCommand._run (package:build_runner/src/entrypoint/build.dart:35:24)
    #74     BuildCommand.run.<anonymous closure> (package:build_runner/src/entrypoint/build.dart:31:15)
    #75     _rootRun (dart:async/zone.dart:1190:13)
    #76     _CustomZone.run (dart:async/zone.dart:1093:19)
    #77     _runZoned (dart:async/zone.dart:1630:10)
    #78     runZoned (dart:async/zone.dart:1550:10)
    #79     withEnabledExperiments (package:build/src/experiments.dart:18:5)
    #80     BuildCommand.run (package:build_runner/src/entrypoint/build.dart:30:12)
    #81     CommandRunner.runCommand (package:args/command_runner.dart:197:27)
    #82     CommandRunner.run.<anonymous closure> (package:args/command_runner.dart:112:25)
    #83     new Future.sync (dart:async/future.dart:223:31)
    #84     CommandRunner.run (package:args/command_runner.dart:112:14)
    #85     run (package:build_runner/src/entrypoint/run.dart:25:31)
    <asynchronous suspension>
    #86     main (file:///C:/_eic/app/eic_app_front/.dart_tool/build/entrypoint/build.dart:27:22)
    #87     _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:297:32)
    #88     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:168:12)
    
    package:analyzer/src/dart/analysis/driver.dart 1347:9                                         AnalysisDriver._computeAnalysisResult2.<fn>
    package:analyzer/src/dart/analysis/performance_logger.dart 32:15                              PerformanceLog.run
    package:analyzer/src/dart/analysis/driver.dart 1294:20                                        AnalysisDriver._computeAnalysisResult2
    package:analyzer/src/dart/analysis/driver.dart 1247:14                                        AnalysisDriver._computeAnalysisResult.<fn>
    dart:async                                                                                    runZoned
    package:analyzer/dart/element/null_safety_understanding_flag.dart 42:12                       NullSafetyUnderstandingFlag.enableNullSafetyTypes
    package:analyzer/src/dart/analysis/driver.dart 1246:40                                        AnalysisDriver._computeAnalysisResult
    package:analyzer/src/dart/analysis/driver.dart 1372:41                                        AnalysisDriver._computeErrors
    package:analyzer/src/dart/analysis/driver.dart 979:20                                         AnalysisDriver.performWork
    package:analyzer/src/dart/analysis/driver.dart 2013:24                                        AnalysisDriverScheduler._run
    package:analyzer/src/dart/analysis/driver.dart 1936:5                                         AnalysisDriverScheduler.start
    package:build_resolvers/src/analysis_driver.dart 62:13                                        analysisDriver
    package:build_resolvers/src/resolver.dart 306:26                                              AnalyzerResolvers._ensureInitialized.<fn>
    package:build_resolvers/src/resolver.dart                                                     AnalyzerResolvers._ensureInitialized.<fn>
    package:build_resolvers/src/resolver.dart 309:6                                               AnalyzerResolvers._ensureInitialized
    package:build_resolvers/src/resolver.dart 314:11                                              AnalyzerResolvers.get
    package:build_runner_core/src/performance_tracking/performance_tracking_resolvers.dart 19:58  PerformanceTrackingResolvers.get.<fn>
    package:build_runner_core/src/generate/performance_tracker.dart 302:15                        _NoOpBuilderActionTracker.trackStage
    package:build_runner_core/src/performance_tracking/performance_tracking_resolvers.dart 19:16  PerformanceTrackingResolvers.get
    package:build                                                                                 BuildStepImpl.resolver
    package:source_gen/src/builder.dart 72:32                                                     _Builder.build
    package:build                                                                                 runBuilder
    package:build_runner_core/src/generate/build_impl.dart 485:19                                 _SingleBuild._runForInput.<fn>.<fn>.<fn>
    package:build_runner_core/src/generate/performance_tracker.dart 302:15                        _NoOpBuilderActionTracker.trackStage
    package:build_runner_core/src/generate/build_impl.dart 483:23                                 _SingleBuild._runForInput.<fn>.<fn>
    package:build_runner_core/src/generate/build_impl.dart                                        _SingleBuild._runForInput.<fn>.<fn>
    package:timing/src/timing.dart 222:44                                                         NoOpTimeTracker.track
    package:build_runner_core/src/generate/build_impl.dart 440:22                                 _SingleBuild._runForInput.<fn>
    package:pool/pool.dart 127:28                                                                 Pool.withResource
    package:build_runner_core/src/generate/build_impl.dart 436:17                                 _SingleBuild._runForInput
    package:build_runner_core/src/generate/build_impl.dart 374:38                                 _SingleBuild._runBuilder.<fn>
    dart:async                                                                                    Future.wait
    package:build_runner_core/src/generate/build_impl.dart 373:36                                 _SingleBuild._runBuilder
    package:build_runner_core/src/generate/build_impl.dart 319:20                                 _SingleBuild._runPhases.<fn>.<fn>
    package:build_runner_core/src/generate/build_impl.dart                                        _SingleBuild._runPhases.<fn>.<fn>
    package:build_runner_core/src/generate/performance_tracker.dart 184:15                        _NoOpBuildPerformanceTracker.trackBuildPhase
    package:build_runner_core/src/generate/build_impl.dart 315:47                                 _SingleBuild._runPhases.<fn>
    package:timing/src/timing.dart 222:44                                                         NoOpTimeTracker.track
    package:build_runner_core/src/generate/build_impl.dart 309:32                                 _SingleBuild._runPhases
    package:build_runner_core/src/logging/logging.dart 25:30                                      logTimedAsync
    package:build_runner_core/src/generate/build_impl.dart 266:26                                 _SingleBuild._safeBuild.<fn>
    dart:async                                                                                    runZoned
    package:build_runner_core/src/generate/build_impl.dart 261:5                                  _SingleBuild._safeBuild
    package:build_runner_core/src/generate/build_impl.dart 208:24                                 _SingleBuild.run
    package:build_runner_core/src/generate/build_impl.dart 94:56                                  BuildImpl.run
    package:build_runner_core/src/generate/build_runner.dart 25:14                                BuildRunner.run
    package:build_runner                                                                          BuildCommand.run
    package:args/command_runner.dart 197:27                                                       CommandRunner.runCommand
    package:args/command_runner.dart 112:25                                                       CommandRunner.run.<fn>
    dart:async                                                                                    new Future.sync
    package:args/command_runner.dart 112:14                                                       CommandRunner.run
    package:build_runner                                                                          run
    .dart_tool\build\entrypoint\build.dart 27:22                                                  main
    

    This is the code of "customers_screen_arguments.dart":

    enum CallingAction { Customers1, CustomersOfAdministrator }
    
    class CustomersScreenArguments {
      final CallingAction callingAction;
      final int administratorCode;
      CustomersScreenArguments(this.callingAction, {this.administratorCode});
    }
    

    This is the result of "flutter --version:

    Flutter 1.22.3 • channel stable • https://github.com/flutter/flutter.git
    Framework • revision 8874f21e79 (3 days ago) • 2020-10-29 14:14:35 -0700
    Engine • revision a1440ca392
    Tools • Dart 2.10.3
    

    This is the pubspec.yaml:

    version: 1.0.0+1
    
    environment:
      sdk: ">=2.7.0 <3.0.0"
    
    dependencies:
      flutter:
        sdk: flutter
      provider: ^4.0.5
      http: ^0.12.0+2
      shared_preferences: ^0.5.6+3
      json_annotation: ^3.0.0
      material_design_icons_flutter: 4.0.5345
       flutter_icons: ^1.1.0 
      url_launcher: ^5.4.10
      
      cupertino_icons: ^0.1.2
    
      package_info: ^0.4.1
    
    dev_dependencies:
      flutter_test:
        sdk: flutter
      json_serializable: ^3.3.0
      build_runner: ^1.6.7
      sqflite: ^1.3.0
      path: ^1.6.4
    
    flutter:
    
      uses-material-design: true
      assets:
        - assets/collaboration.png
    ```
    
    Thank you.
    State: needs info 
    opened by FabioPagano 27
  • Json_serializable is not generating *.g.dart files

    Json_serializable is not generating *.g.dart files

    Given this class:

    import 'dart:typed_data';
    
    import 'package:meta/meta.dart';
    import 'package:json_annotation/json_annotation.dart';
    
    part 'entities.g.dart';
    
    @JsonSerializable(nullable: false)
    class User {
      final String uid;
      final String email;
      final String displayName;
      final String profilePicture;
      final String accountType;
    
      User(
          {@required this.uid,
          @required this.email,
          @required this.displayName,
          @required this.profilePicture,
          this.accountType});
    
      factory User.fromJson(Map<String, dynamic> json) => _$UserFromJson(json);
    
      Map<String, dynamic> toJson() => _$UserToJson(this);
    }
    

    image (Image so you can see what my IDE is highlighting)

    This is inside a dart file called entities.dart image

    This is my pubspec.yaml

    name: <...>
    description: <...>
    
    version: 1.0.0+1
    
    environment:
      sdk: ">=2.6.0 <3.0.0"
    
    dependencies:
      flutter:
        sdk: flutter
    
      google_sign_in: ^4.4.3
      firebase_auth: ^0.16.0
      firebase_core: ^0.4.4+3
      cloud_firestore: ^0.13.5
      google_fonts: ^1.0.0
      json_annotation: ^3.0.1
      provider: ^4.0.5
      url_launcher: ^5.4.5
      image_picker: ^0.6.5+2
      image_picker_web: ^1.0.6
      string_validator: ^0.1.4
      intl_phone_number_input: ^0.3.0
      currency_pickers: ^1.0.6
      i18n_extension: ^1.3.5
      photo_view: ^0.9.2
    
    dev_dependencies:
      build_runner: ^1.9.0
      json_serializable: ^3.3.0
      flutter_test:
        sdk: flutter
      flutter_localizations:
        sdk: flutter
    
    flutter:
      uses-material-design: true
      assets:
        - assets/
    

    I am running the following command: flutter packages pub run build_runner build

    And this is the console output:

    [INFO] Generating build script...
    [INFO] Generating build script completed, took 384ms
    
    [INFO] Initializing inputs
    [INFO] Reading cached asset graph...
    [INFO] Reading cached asset graph completed, took 75ms
    
    [INFO] Checking for updates since last build...
    [INFO] Checking for updates since last build completed, took 741ms
    
    [INFO] Running build...
    [INFO] Running build completed, took 18ms
    
    [INFO] Caching finalized dependency graph...
    [INFO] Caching finalized dependency graph completed, took 51ms
    
    [INFO] Succeeded after 88ms with 0 outputs (0 actions)
    

    I've tried many variations of the class, it simply wont generate anything.

    I've tried a non-optional constructor, removing @required, changing imports, renaming the dart file, invalidating caches and restarting several times, renaming the class, etc...

    opened by SwissCheese5 27
  • Use the extension methods feature to remove need of most boilerplate

    Use the extension methods feature to remove need of most boilerplate

    Starting with Dart 2.6, json_serializable has the option to create the toJson() method for the user. Although extension methods don't support constructors, json_serializable could create a static generative method instead. This means that user code would look like this:

    import 'package:json_annotation/json_annotation.dart';
    
    part 'example.g.dart';
    
    @JsonSerializable(nullable: false)
    class Person {
      final String firstName;
      final String lastName;
      final DateTime dateOfBirth;
      Person({this.firstName, this.lastName, this.dateOfBirth});
    }
    

    The generated extension might look like this:

    // in example.g.dart
    
    extension on Person {
      static Person fromJson(Map<String, dynamic> json) => _$PersonFromJson(json);
    
      Map<String, dynamic> toJson() => _$PersonToJson(this);
    }
    
    // ...
    

    Rest of the code can keep the same.

    State: help wanted Type: enhancement 
    opened by filiph 27
  • support for nested items in @JsonKey(name:)

    support for nested items in @JsonKey(name:)

    It would be great if we could directly access nested items in the name String of @JsonKey. Consider this Json:

    "root_item": {
        "items": [
            {
                "name": "first nested item"
            },
            {
                "name": "second nested item"
            }
        ]
    }
    

    I would like to do:

    @JsonKey(name: "root_item/items")
    List<NestedItem> nestedItems;
    

    Sorry if this is already possible, but i could not find anything.

    State: help wanted Type: enhancement P2 medium 
    opened by KorbinianMossandl 27
  • type '_InternalLinkedHashMap<dynamic, dynamic>' is not a subtype of type 'Map<String, dynamic>' in type cast

    type '_InternalLinkedHashMap' is not a subtype of type 'Map' in type cast

    I get following error, when i want to deserialize an object with a property of type List<> containing another serializeable object. If i change "ChatMember.fromJson(e as Map<String, dynamic>)" to "Map<String, dynamic>.from(e)" everything works perfect. Can you fix this, is there any workaround possible so i can continue my work?

    E/flutter (21470): [ERROR:flutter/shell/common/shell.cc(181)] Dart Error: Unhandled exception:
    E/flutter (21470): type '_InternalLinkedHashMap<dynamic, dynamic>' is not a subtype of type 'Map<String, dynamic>' in type cast
    E/flutter (21470): #0      Object._as (dart:core/runtime/libobject_patch.dart:78:25)
    E/flutter (21470): #1      _$ChatFromJson.<anonymous closure> (file:///C:/Flutter/src/hapi/lib/datamodels/chat.g.dart:13:56)
    E/flutter (21470): #2      MappedListIterable.elementAt (dart:_internal/iterable.dart:414:29)
    E/flutter (21470): #3      ListIterable.toList (dart:_internal/iterable.dart:219:19)
    E/flutter (21470): #4      _$ChatFromJson (file:///C:/Flutter/src/hapi/lib/datamodels/chat.g.dart:14:13)
    E/flutter (21470): #5      new Chat.fromJson (package:hapi/datamodels/chat.dart:22:55)
    E/flutter (21470): #6      ChatsModel.getChats.<anonymous closure>.<anonymous closure>.<anonymous closure> (package:hapi/models/chats_model.dart:24:72)
    E/flutter (21470): #7      FirestoreHelper.fromListToMap.<anonymous closure> (package:hapi/framework/helper/firestorehelper.dart:8:36)
    E/flutter (21470): #8      MapBase._fillMapWithMappedIterable (dart:collection/maps.dart:67:32)
    E/flutter (21470): #9      new LinkedHashMap.fromIterable (dart:collection/linked_hash_map.dart:124:13)
    E/flutter (21470): #10     FirestoreHelper.fromListToMap (package:hapi/framework/helper/firestorehelper.dart:6:16)
    E/flutter (21470): #11     ChatsModel.getChats.<anonymous closure>.<anonymous closure> (package:hapi/models/chats_model.dart:24:31)
    E/flutter (21470): #12     _RootZone.runUnaryGuarded (dart:async/zone.dart:1314:10)
    E/flutter (21470): #13     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:336:11)
    E/flutter (21470): #14     _DelayedData.perform (dart:async/stream_impl.dart:591:14)
    E/flutter (21470): #15     _StreamImplEvents.handleNext (dart:async/stream_impl.dart:707:11)
    E/flutter (21470): #16     _PendingEvents.schedule.<anonymous closure> (dart:async/stream_impl.dart:667:7)
    E/flutter (21470): #17     _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
    E/flutter (21470): #18     _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)
    
    // GENERATED CODE - DO NOT MODIFY BY HAND
    
    part of 'chat.dart';
    
    // **************************************************************************
    // JsonSerializableGenerator
    // **************************************************************************
    
    Chat _$ChatFromJson(Map<String, dynamic> json) {
      return Chat(
          members: (json['members'] as List)
              ?.map((e) =>
                  e == null ? null : ChatMember.fromJson(e as Map<String, dynamic>))
              ?.toList(),
          memberIds: (json['memberIds'] as List)?.map((e) => e as String)?.toList())
        ..creation = json['creation'] == null
            ? null
            : DateTime.parse(json['creation'] as String)
        ..lastUpdate = json['lastUpdate'] == null
            ? null
            : DateTime.parse(json['lastUpdate'] as String);
    }
    
    Map<String, dynamic> _$ChatToJson(Chat instance) => <String, dynamic>{
          'creation': instance.creation?.toIso8601String(),
          'lastUpdate': instance.lastUpdate?.toIso8601String(),
          'members': instance.members,
          'memberIds': instance.memberIds
        };
    
    
    opened by HerrNiklasRaab 27
  • Generate code that supports `implicit-dynamic: false`

    Generate code that supports `implicit-dynamic: false`

    Here's the generated code

    Result _$ResultFromJson(Map<String, dynamic> json) {
      return Result(
        total: json['total'] as String,
        page: json['page'] as int,
        pages: json['pages'] as int,
        tv_shows: (json['tv_shows'] as List)
            ?.map((e) => e == null ? null : Tv.fromJson(e as Map<String, dynamic>))
            ?.toList(),
      );
    }
    
    

    And here's the error.

     error • Missing parameter type for 'e' at lib/demo.g.dart:15:16 • implicit_dynamic_parameter
    

    Link: https://circleci.com/gh/trevorwang/retrofit.dart/150?utm_campaign=vcs-integration-link&utm_medium=referral&utm_source=github-build-link

    Type: enhancement State: blocked P2 medium 
    opened by trevorwang 26
  • Make JsonKey's defaultValue a Function? type

    Make JsonKey's defaultValue a Function? type

    I would like to supply a DateTime.now() as a defaultValue to JsonKey, but as it's not a const it's not possible to add it, however if it was of type Function? i could pass it a function which would return a value in the same way as toJson and fromJson, e.g. static DateTime newDate() => DateTime.now(); This would be a breaking change so not sure if it's feasible, but it would make the API more flexible perhaps?

    Dart SDK version: 2.17.6 (stable) (Tue Jul 12 12:54:37 2022 +0200) on "macos_arm64"

    State: help wanted Type: enhancement P3 low pkg:json_serializable 
    opened by erf 23
  • Add support for nested field names

    Add support for nested field names

    Hi I added support for accessing nested field directly. and I included different examples and all the tests are passed, Please check it I don't know i miss something.

    Thanks

    opened by rebaz94 20
  • Bump actions/checkout from 3.1.0 to 3.2.0

    Bump actions/checkout from 3.1.0 to 3.2.0

    Bumps actions/checkout from 3.1.0 to 3.2.0.

    Release notes

    Sourced from actions/checkout's releases.

    v3.2.0

    What's Changed

    New Contributors

    Full Changelog: https://github.com/actions/checkout/compare/v3...v3.2.0

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies 
    opened by dependabot[bot] 0
  • Bump actions/cache from 3.0.11 to 3.2.2

    Bump actions/cache from 3.0.11 to 3.2.2

    Bumps actions/cache from 3.0.11 to 3.2.2.

    Release notes

    Sourced from actions/cache's releases.

    v3.2.2

    What's Changed

    New Contributors

    Full Changelog: https://github.com/actions/cache/compare/v3.2.1...v3.2.2

    v3.2.1

    What's Changed

    Full Changelog: https://github.com/actions/cache/compare/v3.2.0...v3.2.1

    v3.2.0

    What's Changed

    New Contributors

    ... (truncated)

    Changelog

    Sourced from actions/cache's changelog.

    Releases

    3.0.0

    • Updated minimum runner version support from node 12 -> node 16

    3.0.1

    • Added support for caching from GHES 3.5.
    • Fixed download issue for files > 2GB during restore.

    3.0.2

    • Added support for dynamic cache size cap on GHES.

    3.0.3

    • Fixed avoiding empty cache save when no files are available for caching. (issue)

    3.0.4

    • Fixed tar creation error while trying to create tar with path as ~/ home folder on ubuntu-latest. (issue)

    3.0.5

    • Removed error handling by consuming actions/cache 3.0 toolkit, Now cache server error handling will be done by toolkit. (PR)

    3.0.6

    • Fixed #809 - zstd -d: no such file or directory error
    • Fixed #833 - cache doesn't work with github workspace directory

    3.0.7

    • Fixed #810 - download stuck issue. A new timeout is introduced in the download process to abort the download if it gets stuck and doesn't finish within an hour.

    3.0.8

    • Fix zstd not working for windows on gnu tar in issues #888 and #891.
    • Allowing users to provide a custom timeout as input for aborting download of a cache segment using an environment variable SEGMENT_DOWNLOAD_TIMEOUT_MINS. Default is 60 minutes.

    3.0.9

    • Enhanced the warning message for cache unavailablity in case of GHES.

    3.0.10

    • Fix a bug with sorting inputs.
    • Update definition for restore-keys in README.md

    3.0.11

    • Update toolkit version to 3.0.5 to include @actions/core@^1.10.0
    • Update @actions/cache to use updated saveState and setOutput functions from @actions/core@^1.10.0

    3.1.0-beta.1

    • Update @actions/cache on windows to use gnu tar and zstd by default and fallback to bsdtar and zstd if gnu tar is not available. (issue)

    3.1.0-beta.2

    • Added support for fallback to gzip to restore old caches on windows.

    3.1.0-beta.3

    ... (truncated)

    Commits
    • 4723a57 Revert compression changes related to windows but keep version logging (#1049)
    • d1507cc Merge pull request #1042 from me-and/correct-readme-re-windows
    • 3337563 Merge branch 'main' into correct-readme-re-windows
    • 60c7666 save/README.md: Fix typo in example (#1040)
    • b053f2b Fix formatting error in restore/README.md (#1044)
    • 501277c README.md: remove outdated Windows cache tip link
    • c1a5de8 Upgrade codeql to v2 (#1023)
    • 9b0be58 Release compression related changes for windows (#1039)
    • c17f4bf GA for granular cache (#1035)
    • ac25611 docs: fix an invalid link in workarounds.md (#929)
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies 
    opened by dependabot[bot] 0
  • support decode null value in enum

    support decode null value in enum

    v 4.7.0 for decode enum using next function

    K $enumDecode<K extends Enum, V>(
      Map<K, V> enumValues,
      Object? source, {
      K? unknownValue,
    }) 
    

    with

    if (source == null) {
        throw ArgumentError(
          'A value must be provided. Supported values: '
          '${enumValues.values.join(', ')}',
        );
      }
    

    so if im have next enumValues like

    const _$FeedbackTypeEnumMap = {
      FeedbackType.all: null,
      FeedbackType.delivery: 'DELIVERY',
      FeedbackType.payment: 'PAYMENT',
    };
    

    I cannot decode null value as FeedbackType.all because if (source == null) throw and I have next exception:

    Invalid argument(s): A value must be provided. Supported values: null, DELIVERY, PAYMENT

    for what we use the throw? if next steps is

    for (var entry in enumValues.entries) 
    

    and then

    if (unknownValue == null) {
        throw ArgumentError(
    
    pkg:json_serializable pkg:json_annotation Area: enums 
    opened by EvGeniyLell 0
  • Problems generating classes when complexe object in constructor

    Problems generating classes when complexe object in constructor

    As I got no answer on that on stackoverflow I hope for an answer here.

    When extending a class and serializing a complexe object I get some problems. Ist seems the problem only existing when extending and having the complexe object in the constructor:

    import 'package:json_annotation/json_annotation.dart'; part 'app_user.g.dart';

    @JsonSerializable(explicitToJson: true)
    class AppUser extends BaseUser{
      String name;
    
    
      AppUser(this.name, avatar) : super(avatar);
    
      factory AppUser.fromJson(Map<String, dynamic> json) => _$AppUserFromJson(json);
      Map<String, dynamic> toJson() => _$AppUserToJson(this);
    }
    
    class BaseUser{
      AvatarConfiguration? avatar;
    
      BaseUser(AvatarConfiguration avatar);
    }
    
    @JsonSerializable()
    class AvatarConfiguration{
      @JsonKey(name: "he")
      int head;
      @JsonKey(name: "ha")
      int hair;
      @JsonKey(name: "no")
      int nose;
      @JsonKey(name: "mo")
      int mouth;
      @JsonKey(name: "ey")
      int eye;
    
    
      AvatarConfiguration(this.head, this.hair, this.nose, this.mouth, this.eye);
    
      factory AvatarConfiguration.fromJson(Map<String, dynamic> json) => _$AvatarConfigurationFromJson(json);
    
      Map<String, dynamic> toJson() => _$AvatarConfigurationToJson(this);
    
    }
    

    I get that generated:

    part of 'app_user.dart';
    
    // **************************************************************************
    // JsonSerializableGenerator
    // **************************************************************************
    
    AppUser _$AppUserFromJson(Map<String, dynamic> json) => AppUser(
          json['name'] as String,
          json['avatar'],
        );
    
    Map<String, dynamic> _$AppUserToJson(AppUser instance) => <String, dynamic>{
          'avatar': instance.avatar?.toJson(),
          'name': instance.name,
        };
    
    AvatarConfiguration _$AvatarConfigurationFromJson(Map<String, dynamic> json) =>
        AvatarConfiguration(
          json['he'] as int,
          json['ha'] as int,
          json['no'] as int,
          json['mo'] as int,
          json['ey'] as int,
        );
    
    Map<String, dynamic> _$AvatarConfigurationToJson(
            AvatarConfiguration instance) =>
        <String, dynamic>{
          'he': instance.head,
          'ha': instance.hair,
          'no': instance.nose,
          'mo': instance.mouth,
          'ey': instance.eye,
        };
    
    
    

    and

    json['avatar'],

    is not what I expect.

    When not extending the class

    @JsonSerializable(explicitToJson: true)
    class AppUser{
      String name;
      AvatarConfiguration? avatar;
    
      AppUser(this.name, this.avatar);
    
      factory AppUser.fromJson(Map<String, dynamic> json) => _$AppUserFromJson(json);
      Map<String, dynamic> toJson() => _$AppUserToJson(this);
    }
    

    I get what I expect:

    // **************************************************************************
    // JsonSerializableGenerator
    // **************************************************************************
    
    AppUser _$AppUserFromJson(Map<String, dynamic> json) => AppUser(
          json['name'] as String,
          json['avatar'] == null
              ? null
              : AvatarConfiguration.fromJson(
                  json['avatar'] as Map<String, dynamic>),
        );
    
    Map<String, dynamic> _$AppUserToJson(AppUser instance) => <String, dynamic>{
          'name': instance.name,
          'avatar': instance.avatar?.toJson(),
        };
    ...
    

    Can anyone tell me if that is a bug or does it make sense how json_serializable is working???

    Version is 6.5.3

    [√] Flutter (Channel stable, 3.3.5, on Microsoft Windows [Version 10.0.19044.2130], locale de-DE) • Flutter version 3.3.5 on channel stable at C:\SDKs\flutter_latest\flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision d9111f6402 (8 days ago), 2022-10-19 12:27:13 -0700 • Engine revision 3ad69d7be3 • Dart version 2.18.2 • DevTools version 2.15.0

    ...

    opened by chrisDK1977 3
  • Support for Records

    Support for Records

    With the upcoming records feature, it would be good to figure out how to serialize those with this package.

    I'd propose:

    • Make it an error to mix positional and named fields in an inline type
    • Allow records with only named fields - serializes to a normal JSON map with keys as the field names
    • Allow records with only positional fields - serializes to a normal JSON list (note that the list might not be homogenous)

    Allow records with mixed fields with the following qualifications:

    • only via a typedef - so that we don't have to canonicalize structural types.
    • is converted to a JSON map
    • positional fields require a JsonKey annotation with a name

    Potential other requirements to consider:

    • Only support JsonKey annotation with typedefs - to make it clear we don't canonicalize structural types

    Note that we could probably support not requiring to go through a typedef, it just makes it more error prone for users, because they need to understand that the type is not canonicalized and the annotation would have to be added to all records.

    Finally, we would need to consider what annotating a record type by itself (not embedded in an object) with JsonSerializable would look like. I think creating a toJson extension method would be a good approach. Where to put the fromJson method / how to name it is a bit more tricky.

    Type: enhancement State: blocked pkg:json_serializable 
    opened by TimWhiting 1
  • Custom Map Types

    Custom Map Types

    @kevmoo Iterated as requested on #997

    Fixes: https://github.com/google/json_serializable.dart/issues/396 See hacky workaround that is forced to do this at runtime for the fast_immutable_collections package, and is not able to handle enum keys: https://github.com/marcglasberg/fast_immutable_collections/pull/25/files#diff-ba44d9486dfccb708bbdbbc167a5cfc096361c004eb01907d83fa4cfb2b8b889R1386

    Custom map types with fromJson / toJson methods can now have keys automatically de/serialized to strings.

    Usage:

    Custom map types can make the fromJsonK / toJsonK parameters of their fromJson / toJson methods detected as map keys by using String? rather than Object? as the serialized type.

    // Custom map type with custom serializers 
    // (Example just wraps a map type, but imagine an immutable collections package)
    class CustomMap<K, V> {
      final Map<K, V> map;
    
      CustomMap(this.map);
    
      factory CustomMap.fromJson(
        Map<String, dynamic> json,
        // Json serializable detects this as a custom Key value because of the (String?).
        K Function(String?) fromJsonK,  
        V Function(Object?) fromJsonV,
      ) =>
          CustomMap(json.map<K, V>(
              (key, value) => MapEntry(fromJsonK(key), fromJsonV(value))));
    
      Map<String?, dynamic> toJson( 
        // Json serializable detects this as a custom Key value because of the (String?).
        String? Function(K) toJsonK, 
        Object? Function(V) toJsonV,
      ) =>
          map.map((key, value) => MapEntry(toJsonK(key), toJsonV(value)));
    }
    
    // User of custom map type & JsonSerializable
    @JsonSerializable()
    class UseOfCustomMap {
      final CustomMap<int, String> map;
    
      UseOfCustomMap(this.map);
    
      factory UseOfCustomMap.fromJson(Map<String, dynamic> json) =>
          _$UseOfCustomMapFromJson(json);
    
      Map<String, dynamic> toJson() => _$UseOfCustomMapToJson(this);
    }
    
    opened by TimWhiting 2
Owner
Google
Google ❤️ Open Source
Google
Converts SVG icons to OTF font and generates Flutter-compatible class. Provides an API and a CLI tool.

Fontify The Fontify package provides an easy way to convert SVG icons to OpenType font and generate Flutter-compatible class that contains identifiers

Igor Kharakhordin 88 Oct 28, 2022
A library for Dart that generates fake data

faker A library for Dart that generates fake data. faker is heavily inspired by the Python package faker, and the Ruby package ffaker. Usage A simple

Jesper Håkansson 193 Dec 18, 2022
A builder that generates an ArgsParser from a class

Parse command line arguments directly into an annotation class using the Dart Build System. Example Annotate a class with @CliOptions() from package:b

Kevin Moore 43 Oct 30, 2022
Okan YILDIRIM 37 Jul 10, 2022
Material color utilities

Material color utilities Algorithms and utilities that power the Material Design 3 (M3) color system, including choosing theme colors from images and

null 878 Jan 8, 2023
Utilities to make working with 'Duration's easier.

duration Utilities to make working with 'Duration's easier. NOTE: Use prettyDuration, prettySeconds, prettyMilliseconds instead of printDuration, prin

null 45 Sep 21, 2022
A CLI tool to help generate dart classes from json returned from API

Json 2 Dart Command line utility Important note There is already a package called json2dart so this package will be called json2dartc ! This project w

Adib Mohsin 38 Oct 5, 2022
An auto mapper for Dart. It allows mapping objects of different classes automatically and manually using JSON serialization.

AutoMapper for Dart An auto mapper for Dart. It allows mapping objects of different classes automatically and manually using JSON serialization. Examp

Leynier Gutiérrez González 7 Aug 24, 2022
A generator to create config class from json files that support many environments

A generator to create config class from json files that support many environments. Motivation If you use a json file to config your applications, perp

Diego Cardenas 0 Oct 9, 2021
A flutter package that allows you to transform your excel to json

excel_to_json A package that allows you to transform your excel to the following format: Excel To JSON Getting Started At current the package allows y

Vitor Amaral de Melo 0 Nov 7, 2022
JSON API parser for Flutter

Flutter Japx - JSON:API Decoder/Encoder Lightweight [JSON:API][1] parser that flattens complex [JSON:API][1] structure and turns it into simple JSON a

Infinum 23 Dec 20, 2022
library to help you create database on local memory, support json local database inspired by lowdb

Licensed Licensed under the MIT License <http://opensource.org/licenses/MIT>. SPDX-License-Identifier: MIT Copyright (c) 2021 Azkadev <http://github.c

Azka Full Snack Developer:) 35 Oct 17, 2022
A flutter application , that create dynamic forms from json data

checktyper A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you started if th

DotCoder 1 Aug 23, 2022
Cache json map to local file with Dart:io. Read file with sync api.

local_cache_sync 一个非常简单易用的Flutter本地储存库,适用于在本地储存一列轻量数据(例如用户保存在本地的设备信息,或者缓存一系列用户信息)。 local_cache_sync的所有方法都是同步,而不是异步的。这意味着你不需要使用await就可以获取数据。在flutter中,这

null 16 Jun 24, 2022
From JSON to Dart Advanced

From JSON to Dart Advanced Table of Contents Features Convert from clipboard Convert from selection Convert from clipboard to code generation Convert

 нιяαитнα 80 Dec 17, 2022
Args simple - A simple argument parser and handler, integrated with JSON and dart

args_simple A simple argument parser and handler, integrated with JSON and dart:

Graciliano Monteiro Passos 1 Jan 22, 2022
This package allows programmers to annotate Dart objects in order to Serialize / Deserialize them to / from JSON

This package allows programmers to annotate Dart objects in order to Serialize / Deserialize them to / from JSON. Why? Compatible with all target plat

Alexander Mazuruk 356 Jan 6, 2023
Serialize almost everything you ever need! 📦 Supports serializing MaterialColor, Color, Size, Locale, IconData, UuidValue, DateTime, Directory, File, Duration, and many more.

osum_serializable The goal is to serialize almost everything you ever need! json_serializable is an amazing package to serialize classes but cannot se

Aswin Murali 2 Sep 23, 2022
🎯 This library automatically generates object classes from JSON files that can be parsed by the freezed library.

The Most Powerful Way to Automatically Generate Model Objects from JSON Files ⚡ 1. Guide ?? 1.1. Features ?? 1.1.1. From 1.1.2. To 1.2. Getting Starte

KATO, Shinya / 加藤 真也 14 Nov 9, 2022
Provides null-safety implementation to simplify JSON data handling by adding extension method to JSON object

Lazy JSON Provides null-safety implementation to simplify JSON data handling by adding extension method to JSON object and JSON array. Getting started

Kinnara Digital Studio 0 Oct 27, 2021