{"id":16625633,"url":"https://github.com/aleclarson/php-serialized","last_synced_at":"2026-05-08T02:14:06.887Z","repository":{"id":57323235,"uuid":"145036071","full_name":"aleclarson/php-serialized","owner":"aleclarson","description":"PHP serialize and unserialize for NodeJS (with useful error messages)","archived":false,"fork":false,"pushed_at":"2020-03-16T21:41:51.000Z","size":13,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-29T20:08:42.390Z","etag":null,"topics":["ast","nodejs","parser","php","serialized"],"latest_commit_sha":null,"homepage":"","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/aleclarson.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":"2018-08-16T20:28:21.000Z","updated_at":"2020-03-16T21:41:51.000Z","dependencies_parsed_at":"2022-09-12T06:30:13.231Z","dependency_job_id":null,"html_url":"https://github.com/aleclarson/php-serialized","commit_stats":null,"previous_names":["aleclarson/php-serialized-ast"],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aleclarson%2Fphp-serialized","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aleclarson%2Fphp-serialized/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aleclarson%2Fphp-serialized/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aleclarson%2Fphp-serialized/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aleclarson","download_url":"https://codeload.github.com/aleclarson/php-serialized/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242995897,"owners_count":20218828,"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":["ast","nodejs","parser","php","serialized"],"created_at":"2024-10-12T04:06:32.992Z","updated_at":"2025-12-24T03:29:40.185Z","avatar_url":"https://github.com/aleclarson.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# php-serialized v1.2.0\n\nPHP `serialize` and `unserialize` for NodeJS (with **useful error messages**)\n\n```js\nconst {serialize, unserialize} = require('php-serialized');\n\nserialize([ null ]);\n// =\u003e 'a:1:{i:0;N;}'\n\nunserialize('a:1:{i:0;N;}');\n// =\u003e [ [0, null] ]\n```\n\nThe return value of `unserialize` is always an array.\n\nBy default, array nodes are *not* converted in any way.\n\nPass a function to transform parsed arrays.\n\n```js\nunserialize('a:1:{i:0;N;}', (arr) =\u003e {\n  let res = [];\n  for (let i = 0; i \u003c arr.length; i += 2) {\n    res[arr[i]] = arr[i + 1];\n  }\n  return res;\n});\n// =\u003e [ [null] ]\n```\n\n*Note:* Serialized class instances are not currently supported. Pull requests are encouraged!\n\n\u0026nbsp;\n\n### `parse(str: string, raw: Function | true): Array\u003cNode\u003e`\n\nParse a serialized string into an array of AST nodes.\n\nAny syntax errors are returned in an array. The parser will continue until the end is reached or a fatal error is encountered. This means multiple errors can be returned.\n\nWhen 1+ errors are encountered, the returned array will only contain error nodes. Use `results[0].type !== 'error'` to know if there are no errors.\n\n```js\nconst {parse} = require('php-serialized-ast');\n\nparse('a:0:{}');\n// =\u003e [{ type: 'array', value: [], start: 0, end: 6 }]\n\nparse('a:0:{');\n// =\u003e [{ type: 'error', error: 'Array never closed', start: 0 }]\n```\n\n\u0026nbsp;\n\n### `reduce(ast: Array\u003cNode\u003e | Node) : any`\n\nConvert AST nodes to their raw values using the `reduce` function.\n\nArray nodes are *not* converted in any way.\n\n```js\nconst {reduce, parse} = require('php-serialized-ast');\n\nreduce(parse('a:1:{i:0;N;}')); =\u003e [ [0, null] ]\n```\n\n*Note:* Doing `reduce(parse(str))` will always be slower than doing `unserialize(str)` because of the intermediate AST nodes.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faleclarson%2Fphp-serialized","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faleclarson%2Fphp-serialized","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faleclarson%2Fphp-serialized/lists"}