{"id":20497156,"url":"https://github.com/alexcambose/object-plain-string","last_synced_at":"2026-04-20T01:04:34.653Z","repository":{"id":57148506,"uuid":"105167987","full_name":"alexcambose/object-plain-string","owner":"alexcambose","description":"Convert javascript objects into strings","archived":false,"fork":false,"pushed_at":"2017-10-06T13:34:59.000Z","size":17,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-05-21T04:21:15.001Z","etag":null,"topics":["convert","javascript","json","object","string","text"],"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/alexcambose.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":"2017-09-28T15:49:23.000Z","updated_at":"2023-04-11T15:21:25.000Z","dependencies_parsed_at":"2022-09-06T18:10:15.817Z","dependency_job_id":null,"html_url":"https://github.com/alexcambose/object-plain-string","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexcambose%2Fobject-plain-string","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexcambose%2Fobject-plain-string/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexcambose%2Fobject-plain-string/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexcambose%2Fobject-plain-string/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alexcambose","download_url":"https://codeload.github.com/alexcambose/object-plain-string/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242087867,"owners_count":20069722,"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":["convert","javascript","json","object","string","text"],"created_at":"2024-11-15T18:10:12.691Z","updated_at":"2026-04-20T01:04:29.615Z","avatar_url":"https://github.com/alexcambose.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status via Travis CI](https://travis-ci.org/alexcambose/object-plain-string.svg?branch=master)](https://travis-ci.org/alexcambose/object-plain-string)\n\n# object-plain-string\nConvert javascript objects into strings\n\n## Installation\n```\nnpm i -S object-plain-string\n```\n[npm](https://www.npmjs.com/package/object-plain-string)\n\n## Usage\n\n```js\nconst convert = require('object-plain-string');\n\nconst obj = {\n  key1: \"Value for key1\",\n  key2: \"Value for key2\",\n  key3: {\n      key31: \"Value for key31\",\n      key32: \"Value for key32\",\n  }\n};\n\nconst result = convert(obj);\nconsole.log(result);\n/*\n\"{\n    key1: 'Value for key1',\n    key2: 'Value for key2',\n    key3: {\n        key31: 'Value for key31',\n        key32: 'Value for key32',\n    },\n},\"\n*/\n```\n\n```js\nconst convert = require('object-plain-string');\nconst obj = {\n    key1: 'This is key1',\n    key2: 'This is key2',\n    integer: 123,\n    boolean: true,\n    array: [1,2,3,4],\n    func: function (){\n        //comment\n        console.log('this is a function');\n    },\n    object: {\n        deep1: 'This is deep1',\n        deep2: 'This is deep2'\n    },\n    regex: /.css$/,\n    _undefined: undefined,\n    _null: null,\n}\n\nconst result = convert(obj);\nconsole.log(result);\n/*\n\"{\n    key1: 'This is key1',\n    key2: 'This is key2',\n    integer: 123,\n    boolean: true,\n    array: [1,2,3,4,],\n    func: function (){\n        //comment\n        console.log('this is a function');\n    },\n    object: {\n        deep1: 'This is deep1',\n        deep2: 'This is deep2',\n    },\n    regex: /.css$/,\n    _null: null,\n}\"\n*/\n```\n\n`undefined` object key values will be ignored and `null` will be kept\n\n```js\nconst obj = {\n  undefinedValue: undefined,\n  nullValue: null\n};\n\nconst result = convert(obj);\nconsole.log(result);\n/*\n\"{\n  nullValue: null,\n}\"\n*/\n```\n\n\n### Why would you use `object-plain-string` instead of `JSON.stringify`?\nWell, it depends on what you want to achieve, for example if you want to write javascript config files you may want to use `object-plain-string` instead of `JSON.stringify`.\n\n#### `JSON.stringify` vs `object-plain-string`\n```js\nconst convert = require('object-plain-string');\n\nconst obj = {\n    a: 'Some text',\n    b: ()=\u003e{\n        console.log('something');\n    },\n    c: [1,2,{a:'Something'},3,4]\n};\n\nconsole.log(JSON.stringify(obj));\n/*\n{\n    \"a\":\"Some text\",\n    \"c\":[1,2,{\"key\":\"Something\"},3,4]\n}.\n\n*/\n\nconsole.log(convert(obj));\n/*\n\"{\n    a: 'Some text',\n    b: ()=\u003e{\n        console.log('something');\n    }\n    c: [1,2,{\n        key: 'Something',\n    },3,4,],\n},\"\n\n*/\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexcambose%2Fobject-plain-string","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falexcambose%2Fobject-plain-string","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexcambose%2Fobject-plain-string/lists"}