{"id":19513052,"url":"https://github.com/invrs/structured-json","last_synced_at":"2025-11-03T15:02:57.763Z","repository":{"id":91426533,"uuid":"115233059","full_name":"invrs/structured-json","owner":"invrs","description":"Framework for complex JSON configuration structures","archived":false,"fork":false,"pushed_at":"2018-01-28T18:21:46.000Z","size":346,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-01-08T12:10:02.917Z","etag":null,"topics":["configuration","json"],"latest_commit_sha":null,"homepage":"","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/invrs.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}},"created_at":"2017-12-24T01:45:06.000Z","updated_at":"2018-01-04T20:29:25.000Z","dependencies_parsed_at":null,"dependency_job_id":"9b2c1e3b-4369-4569-8db2-fe20f721946b","html_url":"https://github.com/invrs/structured-json","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/invrs%2Fstructured-json","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/invrs%2Fstructured-json/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/invrs%2Fstructured-json/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/invrs%2Fstructured-json/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/invrs","download_url":"https://codeload.github.com/invrs/structured-json/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240762311,"owners_count":19853458,"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":["configuration","json"],"created_at":"2024-11-10T23:28:36.392Z","updated_at":"2025-11-03T15:02:57.707Z","avatar_url":"https://github.com/invrs.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Structured JSON\n\nOperators that make complex JSON structures easy to read and write.\n\n| Action                                | Operator     | Key/Value |\n| ------------------------------------- | ------------ | --------- |\n| [Assign Value](#assign)               | `\u003c=`         | Value     |\n| [Assign Defaults](#defaults)          | `\u003c\u003c`, `\u003e\u003e`   | Key       |\n| [Merge](#merge)                       | `\u003c\u003c`, `\u003e\u003e`   | Value     |\n| [Mixin](#mixin)                       | `$`          | Key       |\n| [Conditional Defaults](#conditionals) | `\u003c\u003c?`, `\u003e\u003e?` | Key       |\n\n## Install\n\n```bash\nnpm install structured-json\n```\n\n## Import\n\n```js\nimport { build, update } from \"structured-json\"\n```\n\n## Assign\n\n```js\nlet { stores, products } = build({\n  stores: {\n    grocery: {\n      products: \"\u003c= products\",\n    },\n  },\n  products: {\n    milk: {\n      store: \"\u003c= stores.grocery\",\n    },\n  },\n})\n\nstores.grocery.products // { milk }\nproducts.milk.store // { products }\n```\n\nAssignment supports circular references, but it is up to you to be careful about infinite enumeration.\n\n## Merge\n\n```js\nlet { products } = build({\n  organicProducts: {\n    eggs: {},\n    milk: {},\n  },\n  veganProducts: {\n    kale: {},\n    tofu: {},\n  },\n  products: \"\u003c= organicProducts \u003c\u003c veganProducts\",\n})\n\nproducts\n// { eggs: {},\n//   milk: {},\n//   kale: {},\n//   tofu: {} }\n```\n\n## Defaults\n\nWhen used in a key, the merge operator defines a default object for its siblings (`\u003e\u003e`) or its parent (`\u003c\u003c`):\n\n```js\nlet { organicProducts, veganProducts } = build({\n  organicProducts: {\n    \"\u003e\u003e\": { organic: true },\n    eggs: {},\n    milk: {},\n  },\n  veganProducts: {\n    \"\u003e\u003e\": { vegan: true },\n    kale: {},\n    tofu: {},\n  },\n})\n\norganicProducts\n// { eggs: { organic },\n//   milk: { organic } }\n\nveganProducts\n// { kale: { vegan },\n//   tofu: { vegan } }\n```\n\nDefine defaults for sibling child objects with successive merge operators (`\"\u003e\u003e \u003e\u003e\":`).\n\n## Mixin\n\nA mixin is a variable meant only for referencing, and does not show up in enumeration.\n\n```js\nlet { products } = build({\n  products: {\n    $green: {\n      color: \"green\",\n    },\n    $white: {\n      color: \"white\",\n    },\n    milk: { \"\u003c\u003c\": \"\u003c= $white\" },\n    kale: { \"\u003c\u003c\": \"\u003c= $green\" },\n    tofu: { \"\u003c\u003c\": \"\u003c= $white\" },\n  },\n})\n\nproducts\n// { milk: { color: \"white\" },\n//   kale: { color: \"green\" },\n//   tofu: { color: \"white\" } }\n```\n\n## Conditionals\n\n```js\nlet { products } = build({\n  winter: true,\n  products: {\n    \"\u003e\u003e? winter\": {\n      local: false,\n    },\n    \"\u003e\u003e\": {\n      local: true,\n    },\n    kale: {},\n  },\n})\n\nproducts // { kale: { local: false } }\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finvrs%2Fstructured-json","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finvrs%2Fstructured-json","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finvrs%2Fstructured-json/lists"}