{"id":17049064,"url":"https://github.com/toddself/jsondom","last_synced_at":"2025-04-12T16:12:50.306Z","repository":{"id":10355900,"uuid":"12494469","full_name":"toddself/jsondom","owner":"toddself","description":"A DOM-like interface for traversing Javascript Objects","archived":false,"fork":false,"pushed_at":"2014-05-15T16:51:51.000Z","size":180,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":16,"default_branch":"master","last_synced_at":"2025-04-10T16:08:55.588Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/toddself.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":"2013-08-30T20:00:07.000Z","updated_at":"2019-05-30T06:10:11.000Z","dependencies_parsed_at":"2022-09-08T13:11:57.546Z","dependency_job_id":null,"html_url":"https://github.com/toddself/jsondom","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toddself%2Fjsondom","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toddself%2Fjsondom/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toddself%2Fjsondom/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toddself%2Fjsondom/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/toddself","download_url":"https://codeload.github.com/toddself/jsondom/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248586241,"owners_count":21128998,"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-14T09:53:46.901Z","updated_at":"2025-04-12T16:12:50.276Z","avatar_url":"https://github.com/toddself.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![build status](https://secure.travis-ci.org/toddself/jsondom.png)](http://travis-ci.org/CondeNast/jsondom)\n\n# JSON DOM\nA DOM-like interface for querying complex Javascript objects. (Also a very light wrapper around [js-traverse](/substack/js-traverse)).\n\n## Installation\n\n```\nnpm install jsondom\n```\n\n## Usage\n\n```js\n\u003e var jsd = require('jsondom');\n\u003e var complex = {\n  title: \"this is a test\",\n  articles: [\n    {\n      title: \"sub title\",\n      articles: \"this is an article\"\n    },\n    {\n      hello: \"it is me you're looking for\"\n    }\n  ]\n};\n\n\u003e jsd.getValuesByKeyName(complex, 'title');\n[\"this is a test\", \"sub title\"]\n\n\u003e jsd.getValuesByKeyName(complex, 'title', 1);\n[\"this is a test\"]\n\n\u003e jsd.getNodesMatching(complex, 'articles');\n[\n  [\n    {\n      title: 'sub title',\n      articles: 'this is an article'\n    },\n    {\n      hello: 'it is me you\\'re looking for'\n    }\n  ],\n  'this is an article'\n]\n\n\u003e js.getNodesMatching(complex, 'articles', true);\n[ { title: 'this is a test',\n    articles: [ [Object], [Object] ] },\n  { title: 'sub title',\n    articles: 'this is an article' } ]\n```\n\n## Methods\n\n### `getValuesFromPartialPath(tree, key)`\n\n```\n/**\n * Gets an array of values from a path which ends with the given path fragment.\n * This method optionally takes an array to generate the path end data from\n * @param  {Object} tree Object graph\n * @param  {Mixed}  key  String or Array\n * @return {Array}       Array of values matching partial path\n */\n```\n\n### `valueFromPath(tree, key_array, getParent)`\n\n```\n/**\n * Takes an array of nodes to the content location and returns the value located\n * at that point. Can we used to return the parent node as well.\n * @param  {Object}   tree        Object graph\n * @param  {Array}    key_array   An array of keys, traversable from the left\n * @param  {Boolean}  (getParent) Flag to return parent or element. Default: element\n * @return {Mixed}                The content located at that point in the tree\n */\n```\n\n### `getPathToKey(tree, key)`\n\n```\n/**\n * Gets the path to a particular key in the Object\n * @param  {Object} tree Object graph\n * @param  {Mixed}  key  String or RegExp\n * @return {Array}       Array of decimal separated paths to object suitable to\n *                       use with valueFromKeyPath\n */\n```\n\n### `getNodesMatching(tree, needle, parent)`\n\n```\n/**\n * Returns a node of the tree if any of the keys or values in the node match the\n * provided criteria\n * @param  {Object}   tree      Object graph\n * @param  {Mixed}    needle    A string or RegExp describing what to find\n * @param  {Boolean}  (parents) Should it return the parent of the matching element\n * @return {Array}              An array of parent nodes which have matching children\n */\n};\n```\n\n### `getValuesByKey(tree, key, maxDepth)`\n\n```\n/**\n * Gets all values from object graph that exist at the specified key name\n * @param  {Object}   tree       Object graph\n * @param  {Mixed}    key        A RegExp or string for the key you're trying to find\n * @param  {Integer}  (maxDepth) Max recursion depth\n * @return {Array}               Array of values from matching keys\n */\n```\n\n## License\nCopyright 2013 Condé Nast. Licensed under the MIT License.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftoddself%2Fjsondom","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftoddself%2Fjsondom","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftoddself%2Fjsondom/lists"}