{"id":19191827,"url":"https://github.com/lambdabaa/knockout-data","last_synced_at":"2025-02-23T04:27:45.558Z","repository":{"id":17160015,"uuid":"19927028","full_name":"lambdabaa/knockout-data","owner":"lambdabaa","description":"JSON data \u003c\u003e knockout observable bridge","archived":false,"fork":false,"pushed_at":"2014-05-20T23:01:09.000Z","size":436,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-04T07:46:48.635Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lambdabaa.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-05-19T02:35:52.000Z","updated_at":"2015-04-16T14:34:26.000Z","dependencies_parsed_at":"2022-07-20T09:18:42.973Z","dependency_job_id":null,"html_url":"https://github.com/lambdabaa/knockout-data","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lambdabaa%2Fknockout-data","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lambdabaa%2Fknockout-data/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lambdabaa%2Fknockout-data/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lambdabaa%2Fknockout-data/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lambdabaa","download_url":"https://codeload.github.com/lambdabaa/knockout-data/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240271519,"owners_count":19774858,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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-09T11:44:57.917Z","updated_at":"2025-02-23T04:27:45.526Z","avatar_url":"https://github.com/lambdabaa.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"knockout-data\n=============\n\nJSON data \u003c\u003e knockout observable bridge\n\n[Live test suite!](https://gaye.github.io/knockout-data/test/)\n\n### Motivation\n\nSuppose you defined your models in the following way...\n\n```js\nfunction User() {\n  this.yellName = function() {\n    return this.name().toUpperCase() + '!';\n  };\n}\nUser.properties = {\n  name: { multiple: false, model: String }\n};\n\nfunction Comment() {\n  this.commentLength = ko.computed(function() {\n    return this.body().length;\n  }.bind(this));\n}\nComment.prototype.body = ko.observable();\nComment.properties = {\n  author: { multiple: false, model: User },\n  body: { multiple: false, model: String }\n};\n\nfunction Post() {\n}\nPost.properties = {\n  author: { multiple: false, model: User },\n  body: { multiple: false, model: String },\n  comments: { multiple: true, model: Comment },\n  likes: { multiple: false, model: Number },\n  public: { multiple: false, model: Boolean }\n};\n```\n\nThen suppose further that you load your model data from a JSON source/API. If you're using [knockoutjs](http://knockoutjs.com/) and you'd like to\n\n+ make all of your json objects' properties \"ko.observable()\"\n+ interact with `User`, `Post`, and `Comment` like objects with niceties like instance methods\n\nthen `kodata` is just what you need!\n\n### Usage\n\n#### kodata.fromJSONValue(model, data)\n\nRecursively hydrates json data into an instance of model, makes all `Boolean`, `String`, and `Number` properties observable. Resolves one-to-many relationship with observable arrays.\n\n#### kodata.toJSONValue(model, instance)\n\nDehydrates an instance of model into json data.\n\nSee the [test suite](https://github.com/gaye/knockout-data/tree/master/test) for fuller examples of how to use `kodata`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flambdabaa%2Fknockout-data","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flambdabaa%2Fknockout-data","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flambdabaa%2Fknockout-data/lists"}