{"id":13555099,"url":"https://github.com/alemures/fast-json","last_synced_at":"2025-04-03T07:34:07.629Z","repository":{"id":10209265,"uuid":"64975351","full_name":"alemures/fast-json","owner":"alemures","description":"A lightning fast on the fly JSON parser","archived":false,"fork":false,"pushed_at":"2023-03-12T21:29:56.000Z","size":21767,"stargazers_count":127,"open_issues_count":4,"forks_count":10,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-31T11:04:49.036Z","etag":null,"topics":["fast","json","json-parser","nodejs","performance"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/alemures.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2016-08-05T00:11:04.000Z","updated_at":"2024-09-18T10:45:30.000Z","dependencies_parsed_at":"2024-06-18T19:59:54.592Z","dependency_job_id":null,"html_url":"https://github.com/alemures/fast-json","commit_stats":{"total_commits":88,"total_committers":2,"mean_commits":44.0,"dds":"0.022727272727272707","last_synced_commit":"450da06e54e9222acd5d0d1fd201b378c91743f4"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alemures%2Ffast-json","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alemures%2Ffast-json/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alemures%2Ffast-json/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alemures%2Ffast-json/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alemures","download_url":"https://codeload.github.com/alemures/fast-json/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":222935631,"owners_count":17060398,"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":["fast","json","json-parser","nodejs","performance"],"created_at":"2024-08-01T12:03:01.837Z","updated_at":"2024-11-04T03:31:47.528Z","avatar_url":"https://github.com/alemures.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"# fast-json\n\nA lightning fast on the fly **JSON parser** able to return JSON values and structures from plain JSON as `String` or `Buffer`. It's much faster than JSON.parse() and doesn't require any extra memory allocation for the data processed.\n\n## Install\n\n```\nnpm install fast-json\n```\n\n## Usage\n\n```javascript\nconst { FastJson } = require('fast-json');\n\nconst data = JSON.stringify({\n  ireland: {\n    people: [{ name: 'Alex' }, { name: 'John' }, { name: 'Cian' }],\n  },\n  spain: {\n    people: [{ name: 'Antonio' }, { name: 'Juan' }, { name: 'Pedro' }],\n  },\n});\n\nconst fastJson = new FastJson();\n\n// Path is a string representing a javascript object path\nfastJson.on('ireland.people', (value) =\u003e {\n  console.log('ireland.people -\u003e', value);\n});\n\n// Paths can be also an array of keys\nfastJson.on(['spain', 'people', '1', 'name'], (value) =\u003e {\n  console.log(['spain', 'people', '1', 'name'], '-\u003e', value);\n});\n\n// Wildcards can be used to match all items in object or array\nfastJson.on('spain.people[*].name', (value) =\u003e {\n  console.log('spain.people[*].name -\u003e', value);\n});\n\nfastJson.on('*.people[*].name', (value) =\u003e {\n  console.log('*.people[*].name -\u003e', value);\n});\n\nfastJson.write(data);\n// The JSON can be string or Buffer\n// fastJson.write(Buffer.from(data))\n```\n\n```javascript\nfastJson.on('ireland.people[1].name', (value) =\u003e {\n  console.log('ireland.people[1].name -\u003e', value);\n  // Once we have all we need, we can skip the rest of the JSON to improve performance.\n  fastJson.skip();\n});\n```\n\n```javascript\n// Path separator defines the keys separator on the listeners\nconst fastJson = new FastJson({ pathSeparator: '/' });\n\n// In this case it allows keys having dots by using a different separator\nfastJson.on('unknown.country/people/0/name', (value) =\u003e {\n  console.log('unknown.country/people/0/name -\u003e', value);\n});\n```\n\n## Performance\n\nJSON file _citylots.json_ of **189MB** from https://github.com/zemirco/sf-city-lots-json.\n\n- **fast-json: 0.56s / 198MB RAM**\n- JSON.parse: 1.8s / 640MB RAM\n- jsonparse: 15.0s / 1,100MB RAM (Only reading, it wasn't able to return a value)\n\n## TODO\n\n- [**Feature**] Allow chunked JSON.\n- [**Feature**] Match more glob patters.\n- [**Feature**] Add more flexibility to event listeners (on, once, off, etc).\n- [**Documentation**] Create branch gh-pages using _jsdoc_.\n- [**Documentation**] More real life testing and examples.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falemures%2Ffast-json","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falemures%2Ffast-json","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falemures%2Ffast-json/lists"}