{"id":17348454,"url":"https://github.com/tremby/json-multi-parse","last_synced_at":"2025-04-14T21:12:15.237Z","repository":{"id":57285027,"uuid":"152924983","full_name":"tremby/json-multi-parse","owner":"tremby","description":"A node module to parse multiple objects out of a JSON string","archived":false,"fork":false,"pushed_at":"2023-05-29T22:36:55.000Z","size":13,"stargazers_count":8,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-28T09:21:23.073Z","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/tremby.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":"2018-10-14T00:11:15.000Z","updated_at":"2023-11-16T03:32:08.000Z","dependencies_parsed_at":"2024-06-21T05:43:38.778Z","dependency_job_id":"86b94053-debe-4582-b873-46aef540bab7","html_url":"https://github.com/tremby/json-multi-parse","commit_stats":{"total_commits":18,"total_committers":2,"mean_commits":9.0,"dds":0.05555555555555558,"last_synced_commit":"7dfedcfa039ede079e4d39b7dc3de13223c17b96"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tremby%2Fjson-multi-parse","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tremby%2Fjson-multi-parse/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tremby%2Fjson-multi-parse/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tremby%2Fjson-multi-parse/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tremby","download_url":"https://codeload.github.com/tremby/json-multi-parse/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248654031,"owners_count":21140236,"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-15T16:52:29.472Z","updated_at":"2025-04-14T21:12:15.213Z","avatar_url":"https://github.com/tremby.png","language":"JavaScript","readme":"json-multi-parse\n================\n\nThis is a simple Node module to parse multiple JSON objects from a single\nsource, such as the following:\n\n    {\"object 1\": \"value 1\"}{\"object 2\":\"value 2\"}\n\nThere can be whitespace between objects.\nBare JSON types other than objects,\nlike strings, arrays, booleans, and numbers,\nmay or may not be supported depending on the Javascript engine being used.\n\nAn array is always returned on success.\nOtherwise, an error thrown by `JSON.parse` is rethrown.\n\nRegex solutions such as splitting on `}{` won't work since that could appear in\na string inside the JSON object.\n\nAn option `partial` is available to handle ending partway through a JSON object.\nIf this is enabled, and such an unexpected ending is encountered,\nthe returned array will have an extra property `remainder`\ncontaining the remaining partial JSON string.\n\nTypescript types are included.\n\nInstallation\n------------\n\n    npm install json-multi-parse\n\nUsage\n-----\n\n    jsonMultiParse = require('json-multi-parse');\n\n    parsed = jsonMultiParse('{\"object 1\": \"value 1\"}{\"object 2\":\"value 2\"}');\n    console.log(parsed.length); // 2\n    console.log(parsed.remainder); // undefined\n\n    parsed = jsonMultiParse('{\"object 1\": \"value 1\"}{\"object 2\":\"value 2\"}', {partial: true});\n    console.log(parsed.length); // 2\n    console.log(parsed.remainder); // ''\n\n    parsed = jsonMultiParse('{\"object 1\": \"value 1\"}{\"obje', {partial: true});\n    console.log(parsed.length); // 1\n    console.log(parsed.remainder); // '{\"obje'\n\n### Typescript\n\nThe default type of each item of the returned array is `any`.\nThis can be overridden if you are certain of what you will be receiving,\nby passing a type to the generic:\n\n    const parsed = jsonMultiParse\u003cMyObjectType\u003e('...'); // MyObjectType[]\n\nIf you are not totally certain about the data you're receiving,\nlike if it's from a 3rd-party API or from user input,\nit's safer to do some type validation/narrowing, such as via\n[type predicates](https://www.typescriptlang.org/docs/handbook/2/narrowing.html#using-type-predicates),\nor maybe using something like [Zod](https://zod.dev/).\n\nWarning\n-------\n\nThis relies on the error message `JSON.parse` throws when trying to parse such a\nstring. It may therefore be brittle.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftremby%2Fjson-multi-parse","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftremby%2Fjson-multi-parse","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftremby%2Fjson-multi-parse/lists"}