{"id":18687356,"url":"https://github.com/junosuarez/dotjson","last_synced_at":"2025-11-08T02:30:32.466Z","repository":{"id":6146006,"uuid":"7375013","full_name":"junosuarez/dotjson","owner":"junosuarez","description":"npm module: get/set api for .json files, like config files","archived":false,"fork":false,"pushed_at":"2012-12-30T22:39:14.000Z","size":124,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-15T16:46:17.072Z","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/junosuarez.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":"2012-12-30T09:09:23.000Z","updated_at":"2021-06-14T03:04:49.000Z","dependencies_parsed_at":"2022-08-24T21:10:40.965Z","dependency_job_id":null,"html_url":"https://github.com/junosuarez/dotjson","commit_stats":null,"previous_names":["jden/dotjson"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/junosuarez%2Fdotjson","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/junosuarez%2Fdotjson/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/junosuarez%2Fdotjson/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/junosuarez%2Fdotjson/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/junosuarez","download_url":"https://codeload.github.com/junosuarez/dotjson/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239545371,"owners_count":19656769,"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-07T10:32:32.259Z","updated_at":"2025-11-08T02:30:32.434Z","avatar_url":"https://github.com/junosuarez.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# dotjson\nget/set api for .json files, like config files\n\n## usage example\n\n    var dotjson = require('dotjson')\n\n    // get the version from package.json\n    var version = dotjson.get('./node_modules/package.json', 'version')\n\n    // set some configuration options, creating the file if it doesn't exist\n    dotjson.set('.conf',\n    {\n      powerLevel: 9001\n    , robotMorale: 'high and steady'\n    , isRaining: false\n    },\n    {createFile: true})\n\n\n## api\n\n### `dotjson.get(filename, path)`\n\nReads the contents of `filename` and returns the value of `path`. `path` can be a single path or an array of paths. if it's a single path, `get` returns it. if it's an array of paths, `get` returns an array of values in the same order, like `Array.prototype.map`. If the path is not found, the value will be undefined.\n\nThrows an error if there is a problem reading from the file.\n\n\n### `dotjson.set(filename, setter, opts)`\n\nOpens `filename` and upserts it according to `setter`, an object map of paths and values. For example, if the config file currently contains `{name: {first: 'alice', last: 'cooper'}}`, then the following setter would update the config to refer to a certain reporter:\n\n    {\n      'name.first': 'anderson'\n    }\n\nSince `setter` is an object, you can specify multiple path/value pairs to set in one operation.\n\n`opts` is an (optional) options object.\n\nOptions:\n* `createFile` (boolean, default false) - attempt to create the file if it does not already exist\n\nThrows an error if there is a problem writing to the file.\n\nReturns void.\n\n\n## path notation\nThis module uses [mongodb dot notation](http://docs.mongodb.org/manual/reference/glossary/#term-dot-notation\n) for paths. It's simple, really - imagine you're writing javascript using only [] bracket accessor notation. Now do that, but with dots instead, including for array indices. See also [@rauchg](https://npmjs.org/~rauchg)'s module, [dot-component](https://npmjs.org/package/dot-component).\n\n\n## tests\nrun `npm test` from the root module directory\n\n\n## zomg, BLOCKING, wtf? o_O\nYes, it's meant for working with tiny json config files in cli scripts. If things like performance, memory usage, or concurrency are important, this might not be your module. If you just want to work with json config files with ease, read on.\n\n\n## license\nMIT\n(c) 2012 jden - Jason Denizac \u003cjason@denizac.org\u003e\nhttp://jden.mit-license.org/2012","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjunosuarez%2Fdotjson","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjunosuarez%2Fdotjson","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjunosuarez%2Fdotjson/lists"}