{"id":20664009,"url":"https://github.com/flutterando/dson_adapter","last_synced_at":"2026-03-07T09:04:33.972Z","repository":{"id":65216516,"uuid":"588288644","full_name":"Flutterando/dson_adapter","owner":"Flutterando","description":" Convert JSON to Dart Class withless code generate(build_runner)","archived":false,"fork":false,"pushed_at":"2024-07-10T03:49:01.000Z","size":35,"stargazers_count":22,"open_issues_count":0,"forks_count":9,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-09-10T05:58:44.898Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Flutterando.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-01-12T19:17:02.000Z","updated_at":"2024-10-28T19:57:10.000Z","dependencies_parsed_at":"2024-11-16T21:17:25.492Z","dependency_job_id":null,"html_url":"https://github.com/Flutterando/dson_adapter","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Flutterando/dson_adapter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Flutterando%2Fdson_adapter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Flutterando%2Fdson_adapter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Flutterando%2Fdson_adapter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Flutterando%2Fdson_adapter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Flutterando","download_url":"https://codeload.github.com/Flutterando/dson_adapter/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Flutterando%2Fdson_adapter/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30210385,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-07T09:02:10.694Z","status":"ssl_error","status_checked_at":"2026-03-07T09:02:08.429Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-16T19:21:36.758Z","updated_at":"2026-03-07T09:04:33.935Z","avatar_url":"https://github.com/Flutterando.png","language":"Dart","readme":"# DSON\n\nConvert JSON to Dart Class withless code generate(build_runner).\n\n## A simple Object\n\n```dart\nclass Person {\n  final int id;\n  final String name;\n  final int age;\n\n  Person({\n    required this.id,\n    required this.name,\n    required this.age,\n  });\n}\n```\n\nConvert json to Object:\n\n```dart\nmain(){\n     final jsonMap = {\n      'id': 1,\n      'name': 'Joshua Clak',\n      'age': 3,\n    };\n\n    Person person = dson.fromJson(jsonMap, Person.new);\n\n    print(person.id);\n    print(person.name);\n    print(person.age);\n}\n\n\n```\n\n## A complex object:\n\nFor complex objects it is necessary to declare the constructor in the `inner` property;\n\n```dart\nmain(){\n    final jsonMap = {\n      'id': 1,\n      'name': 'MyHome',\n      'owner': {\n        'id': 1,\n        'name': 'Joshua Clak',\n        'age': 3,\n      },\n    };\n\n    Person person = dson.fromJson(\n      jsonMap,\n      Person.new,\n      inner: {\n        'owner':  Person.new,\n      }\n    );\n\n    print(person);\n}\n\n```\n\n## A complex object with List:\n\nFor work with a list, it is necessary to declare the constructor in the `inner` property and declare\nthe list resolver in the `resolvers` property.\n\n```dart\nmain(){\n    final jsonMap = {\n      'id': 1,\n      'name': 'MyHome',\n      'owner': {\n        'id': 1,\n        'name': 'Joshua Clak',\n        'age': 3,\n      },\n      'parents': [\n        {\n          'id': 2,\n          'name': 'Kepper Vidal',\n          'age': 25,\n        },\n        {\n          'id': 3,\n          'name': 'Douglas Bisserra',\n          'age': 23,\n        },\n      ],\n    };\n\n    Home home = dson.fromJson(\n      // json Map or List\n      jsonMap,\n      // Main constructor\n      Home.new,\n      // external types\n      inner: {\n        'owner': Person.new,\n        'parents': ListParam\u003cPerson\u003e(Person.new),\n      },\n    );\n\n    print(home);\n}\n\n```\n\nDSON Have `ListParam` and `SetParam` for collection.\n\n## When API replace Param Name (Set aliases):\n\nYou need to declare within the aliases map the object type that has changed in the key, and in the value, a map with the old key as the key and the new key as the value.\n\n```dart\nmain(){\n    final jsonMap = {\n      'id': 1,\n      'name': 'MyHome',\n      'master': {\n        'key': 1,\n        'name': 'Joshua Clak',\n        'age': 3,\n      },\n      'parents': [\n        {\n          'key': 2,\n          'name': 'Kepper Vidal',\n          'age': 25,\n        },\n        {\n          'key': 3,\n          'name': 'Douglas Bisserra',\n          'age': 23,\n        },\n      ],\n    };\n\n    Home home = dson.fromJson(\n      // json Map or List\n      jsonMap,\n      // Main constructor\n      Home.new,\n      // external types\n      inner: {\n        'owner': Person.new,\n        'parents': ListParam\u003cPerson\u003e(Person.new),\n      },\n      // Param names Object \u003c-\u003e Param name in API\n      aliases: {\n        Home: {'owner': 'master'},\n        Person: {'id': 'key'}\n      }\n    );\n\n    print(home);\n}\n\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflutterando%2Fdson_adapter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fflutterando%2Fdson_adapter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflutterando%2Fdson_adapter/lists"}