{"id":21216690,"url":"https://github.com/chharvey/requirejson","last_synced_at":"2025-03-15T00:41:38.820Z","repository":{"id":57101506,"uuid":"164269358","full_name":"chharvey/requirejson","owner":"chharvey","description":"Require JSON files with a file extension other than `.json`.","archived":false,"fork":false,"pushed_at":"2021-01-24T03:21:17.000Z","size":18,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-21T15:52:09.325Z","etag":null,"topics":["json","node","require"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/@chharvey/requirejson","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chharvey.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-01-06T02:42:01.000Z","updated_at":"2021-01-24T03:21:15.000Z","dependencies_parsed_at":"2022-08-20T22:40:42.205Z","dependency_job_id":null,"html_url":"https://github.com/chharvey/requirejson","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chharvey%2Frequirejson","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chharvey%2Frequirejson/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chharvey%2Frequirejson/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chharvey%2Frequirejson/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chharvey","download_url":"https://codeload.github.com/chharvey/requirejson/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243667965,"owners_count":20328036,"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":["json","node","require"],"created_at":"2024-11-20T21:55:09.912Z","updated_at":"2025-03-15T00:41:38.794Z","avatar_url":"https://github.com/chharvey.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# requirejson\nRequire JSON files with a file extension other than `.json`.\n\n# Install\n```\n$ npm install @chharvey/requirejson\n```\n\n# Use\n\n## Asynchronously\n```js\nconst {requireJSON} = require('@chharvey/requirejson');\n\nrequireJSON('./my-file.jsonld').then((my_json_object) =\u003e {\n\tconsole.log(my_json_object['@type']);\n});\n```\n\n## Synchronously\n```js\nconst {requireJSONSync} = require('@chharvey/requirejson');\n\nconst my_json_object = requireJSONSync('./my-file.jsonld');\nconsole.log(my_json_object['@type']);\n```\n\n# API\n```ts\nimport {\n\trequireJSON,\n\trequireJSONSync,\n\tJSONValue,\n\tJSONObject,\n\tJSONArray,\n\tJSONPrimitive,\n} from '@chharvey/requirejson';\n\nconst my_json_object: Promise\u003cJSONValue\u003e = requireJSON('./my-file.jsonld');\nconst my_json_object_sync: JSONValue = requireJSONSync('./my-file.jsonld');\n```\n\n## Functions\n\n### `requireJSON(filepath: string): Promise\u003cJSONValue\u003e`\nAsynchronously returns a JSON value that is the result of parsing the file contents.\n\n#### Parameters:\n- `filepath`: the path of the file to read, relative to current working directory\n\n#### Returns:\nA Promise resolving to a JSON value parsed from the file contents.\n\n### `requireJSONSync(filepath: string): JSONValue`\nSynchronously returns a JSON value that is the result of parsing the file contents.\n\n#### Parameters:\n- `filepath`: the path of the file to read, relative to current working directory\n\n#### Returns:\nA JSON value parsed from the file contents.\n\n## Types\ntype name | definition | description\n----------|------------|------------\nJSONValue | `JSONObject or JSONArray or JSONPrimitive` | Any valid [JSON](http://json.org/) value.\nJSONObject | `{[key: string]?: JSONValue}` | A general JSON object, with string keys and JSONValue values.\nJSONArray | `JSONValue[]` | A JSON array, with JSONValue entries.\nJSONPrimitive | `string or number or boolean or null` | A JSON primitive.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchharvey%2Frequirejson","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchharvey%2Frequirejson","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchharvey%2Frequirejson/lists"}