{"id":16834590,"url":"https://github.com/gobwas/json-compile","last_synced_at":"2025-03-18T02:23:55.387Z","repository":{"id":19953024,"uuid":"23219846","full_name":"gobwas/json-compile","owner":"gobwas","description":"Compilation of references in json.","archived":false,"fork":false,"pushed_at":"2014-12-03T13:05:17.000Z","size":152,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-25T14:46:26.806Z","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/gobwas.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-08-22T09:17:49.000Z","updated_at":"2022-09-23T23:46:02.000Z","dependencies_parsed_at":"2022-08-24T17:50:23.871Z","dependency_job_id":null,"html_url":"https://github.com/gobwas/json-compile","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/gobwas%2Fjson-compile","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gobwas%2Fjson-compile/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gobwas%2Fjson-compile/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gobwas%2Fjson-compile/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gobwas","download_url":"https://codeload.github.com/gobwas/json-compile/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244142138,"owners_count":20404951,"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-10-13T12:07:03.643Z","updated_at":"2025-03-18T02:23:55.368Z","avatar_url":"https://github.com/gobwas.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# [json](http://json.org)-compile\n\n[![npm version](https://badge.fury.io/js/json-compile.svg)](http://badge.fury.io/js/json-compile)\n[![Build Status](https://travis-ci.org/gobwas/json-compile.svg?branch=master)](https://travis-ci.org/gobwas/json-compile)\n\n\u003e Compiles references in given json file into single structure\n\n## Overview\n\nIts about simple inheritance of json configs in your applications. It simply finds out all `$ref` keys inside given file\nand replaces them with referenced values. First will be replaced outer references (to outer files), second - inner references\n(in started with `#` symbol).\n\n## Example\n\nImagine you have base config and his extension.\n\n```js\n// inside /dir/base/extension.json\n{\n    \"$ref\": \"../base.json\",\n    \"host\": \"127.0.0.1\",\n    \"port\": \"8080\"\n}\n\n// inside /dir/base.json\n{\n    \"name\": \"json-compile\"\n}\n```\n\nInside your program you could get compiled config with `json-compile` module:\n\n```js\n// inside your program\nvar compile = require(\"json-compile\"),\n    path    = require(\"path\");\n\ncompile(path.resolve(__dirname, \"./dir/base/extension.json\"), function(err, config) {\n    console.log(typeof config); // object\n    console.log(config); // { \"host\": \"127.0.0.1\", \"port\": \"8080\", \"name\": \"json-compile\" }\n});\n```\n\n## API\n\n### compile(file, [options], [callback])\n\n#### file\n\nType: `String`\n\nPath to input json. Could be absolute, or relative. If relative - then `basedir` property in options must be set.\n\n#### options\n\nType: `Object`\n\nOptions.\n\n\nProperty     | Necessary | Type       | Description\n-------------|-----------|------------|---------------------\n[basedir]    | no        | `string`   | Path to directory, where to find for relatively given path.\n[loader]     | no        | `Function` | Loader for output references. Default uses `fs` module. Has signature `(path, callback)`, where callback is `callback(err, contents)`\n[merge]      | no        | `boolean`  | Merge or not properties, if they are `Object`. Default to `true`.\n\n#### callback\n\nHas signature `(err, result)` where `err` could be a `null` or instance of `Error`, and result is an `Object` with compiled json.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgobwas%2Fjson-compile","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgobwas%2Fjson-compile","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgobwas%2Fjson-compile/lists"}