{"id":25189727,"url":"https://github.com/pioner92/decodable-js","last_synced_at":"2026-04-17T12:33:43.692Z","repository":{"id":124596317,"uuid":"369798170","full_name":"pioner92/decodable-js","owner":"pioner92","description":"Json parse for JavaScript","archived":false,"fork":false,"pushed_at":"2024-01-16T07:24:45.000Z","size":57,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-19T08:29:52.682Z","etag":null,"topics":["decodable","decodable-objects","decode","javascript","js","json","parse","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/pioner92.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2021-05-22T12:06:44.000Z","updated_at":"2025-03-22T20:00:02.000Z","dependencies_parsed_at":null,"dependency_job_id":"e141b277-0c08-47b1-b1d5-55352a8ff72e","html_url":"https://github.com/pioner92/decodable-js","commit_stats":{"total_commits":48,"total_committers":1,"mean_commits":48.0,"dds":0.0,"last_synced_commit":"d9dc607a6622bee542e4f357dd1d4f4f47711080"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/pioner92/decodable-js","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pioner92%2Fdecodable-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pioner92%2Fdecodable-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pioner92%2Fdecodable-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pioner92%2Fdecodable-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pioner92","download_url":"https://codeload.github.com/pioner92/decodable-js/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pioner92%2Fdecodable-js/sbom","scorecard":{"id":734672,"data":{"date":"2025-08-11","repo":{"name":"github.com/pioner92/decodable-js","commit":"f38f4cb3dc268e842b6ecc7e4fb2e911376fdb40"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.6,"checks":[{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":0,"reason":"license file not detected","details":["Warn: project does not have a license file"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'main'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}}]},"last_synced_at":"2025-08-22T15:25:56.536Z","repository_id":124596317,"created_at":"2025-08-22T15:25:56.536Z","updated_at":"2025-08-22T15:25:56.536Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31929783,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-17T10:35:34.458Z","status":"ssl_error","status_checked_at":"2026-04-17T10:35:09.472Z","response_time":62,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: 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":["decodable","decodable-objects","decode","javascript","js","json","parse","typescript"],"created_at":"2025-02-09T21:16:50.152Z","updated_at":"2026-04-17T12:33:43.675Z","avatar_url":"https://github.com/pioner92.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# decodable-js\n\n## Overview\n`decodable-js` is a JavaScript library inspired by Swift's approach to JSON decoding. It verifies the types within JSON data, and based on configuration, can either raise an error for type mismatches or ignore the misaligned fields. It also allows selective data extraction and offers the option to convert between strings and numbers and vice versa.\n\n## Installation\n\nTo integrate `decodable-js` into your project, run one of the following commands:\n\n```bash\n# If you use yarn:\nyarn add decodable-js\n\n# Or if you prefer npm:\nnpm install decodable-js\n```\n\n## Usage\n\nHere's how you can use `decodable-js` in your project:\n\n```typescript\nimport { decodable, T } from 'decodable-js';\n\n// Define your JSON structure\nconst JsonStruct = {\n    age: T.number,\n    address: T.string,\n    visible: T.boolean,\n    numbers: [T.string],\n    salary: T.number_$ // optional\n    // Add more fields as required\n}\n\n// Your JSON data\nconst jsonData = {\n    age: 12,\n    address: '123 Cherry Lane',\n    visible: true,\n    numbers: ['one', 'two', 'three'],\n    rest: ['Will bi skipped']\n    // Additional data...\n}\n\n// Decode the data with type enforcement\nconst result = decodable({data: jsonData, struct: JsonStruct});\n\n// Output the result\nconsole.log(result);\n// {\n//    age: 12,\n//    address: '123 Cherry Lane',\n//    visible: true,\n//    numbers: ['one', 'two', 'three'],\n// }\n```\n```typescript\n\nconst JsonStruct = {\n    numbers: [T.string],\n}\n\n\nconst jsonData = {\n    numbers: [1, '2', '3'], //  1 will be converted to string\n}\n\nconst result = decodable({\n    data: jsonData, \n    struct: JsonStruct,\n    enableConvert: true // enable convert\n});\n\n// Output the result\nconsole.log(result);\n// {\n//    age: 12,\n//    address: '123 Cherry Lane',\n//    visible: true,\n//    numbers: ['1', '2', '3'], // converted to string\n// }\n```\n\n## API Reference\n\n### Types \n- T.number\n- T.string   \n- T.boolean \n- T.object \n- T.null = null\n- T.undefined \n### Optional types (type || undefined)\n- T.number_$ \n- T.string_$ \n- T.boolean_$ \n- T.null_$ \n- T.object_$ \n\nThe main function `decodable()` is used to decode JSON data:\n\n```typescript\nconst result = decodable({\n    data: { index:1 },\n    struct: { \n        index:T.number,\n        value: T.string_$ // optional\n    },\n    enableConvert: false,\n    silentMode: false\n});\n```\n\n- `data: {} | Array\u003cany\u003e` - The JSON data to decode.\n- `struct: {} | Array\u003cany\u003e` - The structure that `data` should be decoded into.\n- `enableConvert: boolean` - If true, enables conversion between strings and numbers (defaults to false).\n- `silentMode: boolean` - If false, throws an error when data does not match the structure (defaults to false).\n\n## Author\n\n- **Alex Shumihin** - Initial work and maintenance.\n\nFor any feedback or issues, please open a GitHub issue or submit a pull request.\n\u003c!-- @import \"[TOC]\" {cmd=\"toc\" depthFrom=1 depthTo=6 orderedList=false} --\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpioner92%2Fdecodable-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpioner92%2Fdecodable-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpioner92%2Fdecodable-js/lists"}