{"id":18086708,"url":"https://github.com/jgfoster/object_serialization","last_synced_at":"2026-03-06T02:36:35.047Z","repository":{"id":229531942,"uuid":"776969641","full_name":"jgfoster/object_serialization","owner":"jgfoster","description":"An object serialization library for Dart that handles circular references and preserves identity.","archived":false,"fork":false,"pushed_at":"2025-06-04T02:11:54.000Z","size":178,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-27T03:33:23.379Z","etag":null,"topics":["dart","serialization-library"],"latest_commit_sha":null,"homepage":"","language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jgfoster.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-03-24T23:27:45.000Z","updated_at":"2025-06-04T02:11:55.000Z","dependencies_parsed_at":"2024-06-24T05:27:13.721Z","dependency_job_id":"668c5592-43b6-4e3a-850f-4da815b00aff","html_url":"https://github.com/jgfoster/object_serialization","commit_stats":null,"previous_names":["jgfoster/object_serialization"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/jgfoster/object_serialization","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jgfoster%2Fobject_serialization","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jgfoster%2Fobject_serialization/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jgfoster%2Fobject_serialization/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jgfoster%2Fobject_serialization/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jgfoster","download_url":"https://codeload.github.com/jgfoster/object_serialization/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jgfoster%2Fobject_serialization/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30159650,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-05T22:39:40.138Z","status":"online","status_checked_at":"2026-03-06T02:00:08.268Z","response_time":250,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["dart","serialization-library"],"created_at":"2024-10-31T16:08:54.068Z","updated_at":"2026-03-06T02:36:35.027Z","avatar_url":"https://github.com/jgfoster.png","language":"Dart","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Pub Package](https://img.shields.io/pub/v/object_serialization.svg)](https://pub.dev/packages/object_serialization)\n\n\nA serialization library that supports circular references and \npreserves identity when objects are referenced via multiple paths. \n\n## Features\n\nMany serialization libraries do not handle circular references; this one does!\nMost serialization libraries do not perserve identity; this one does! \nThat is, when `a` references both `b` and `c`, each of which reference `d`, \nthis library installs the same `d` into both `b` and `c`. \n\n```\n  a\n / \\\nb   c\n \\ /\n  d\n```\n\nConsider the following code in which a list contains two references to\nthe same object (in this case, a String):\n```dart\nfinal s = 'abc';\nfinal list1 = [s, s];\nassert(identical(list1.first, list1.last));\n```\nIf we use `jsonEncode()` and `jsonDecode()`, the referenced object is\nduplicated (object identity is lost):\n\n```dart\nfinal buffer = jsonEncode(list1);\nfinal list2 = jsonDecode(buffer) as List;\nassert(identical(list2.first, list2.last));  // FAILS!\n```\nBut with `object_serializatiion` the referenced object is the same\n(object identity is preserved):\n```dart\nfinal buffer = ObjectSerialization.encode(list1);\nfinal list2 = ObjectSerialization.decode(buffer, {}) as List;\nassert(identical(list2.first, list2.last));  // PASSES!\n```\n\n## Usage\n\nWhile a few simple objects are handled automatically, more complex classes \nshould implement or extend `Serializable`. This requires up to four new\nmethods:\n* `List\u003cObject\u003e get finalProperties` and `List\u003cObject\u003e get transientProperties`\nare used to obtain a list of properties that can be used to recreate the object.\n  * `finalProperties` are those that must be provided _when the object is created_.\n  * `transientProperties` are all other properties.\n* A factory function is used to recreate the object.\n* `set transientProperties(List\u003cObject\u003e properties)` is used to set other properties.\n\nThe reason we can't provide all the properties during creation is that there\nmay be circular references between objects. That is, `a` can reference `b` and\n`b` can reference `a`. Yet, while there can be circular references, they cannot\nboth be `final` since one must exist to be used by the other.\n\nSee the test files for further examples.\n\n## Format\n\nThe encoded data is a JSON list of objects. Each object is a list of three or four values. The first value is the internal object identifier (used to reference this object from elsewhere). The second value is the runtime type for the object (used to recreate the object). If the object is a simple `int` or `string` then the third value is a JSON representation of the object's value. Otherwise, the third value is a list of _final_ properties and the fourth value is a list of _transient_ properties. The final properties are used when recreating the object and the transient properties are updated after the objects are all recreated.\n\n## Additional information\n\nSee https://github.com/jgfoster/object_serialization to contribute code or file issues.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjgfoster%2Fobject_serialization","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjgfoster%2Fobject_serialization","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjgfoster%2Fobject_serialization/lists"}