{"id":25601048,"url":"https://github.com/arifshariati/react-read-write-json","last_synced_at":"2026-04-11T06:02:42.376Z","repository":{"id":125597517,"uuid":"374326193","full_name":"arifshariati/react-read-write-json","owner":"arifshariati","description":"React JS directly can not handle file system function, for which Node JS express comes in handy, where simple route for reading and writing json files and do the job.","archived":false,"fork":false,"pushed_at":"2021-06-07T13:27:39.000Z","size":431,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-02-21T15:51:00.915Z","etag":null,"topics":["express","file-read-write","filesystem","json","material-ui","nodejs","reactjs"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/arifshariati.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-06-06T10:04:53.000Z","updated_at":"2021-06-07T13:31:22.000Z","dependencies_parsed_at":null,"dependency_job_id":"2fad6034-02ab-4efc-ba26-c5f2a18eb637","html_url":"https://github.com/arifshariati/react-read-write-json","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/arifshariati/react-read-write-json","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arifshariati%2Freact-read-write-json","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arifshariati%2Freact-read-write-json/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arifshariati%2Freact-read-write-json/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arifshariati%2Freact-read-write-json/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/arifshariati","download_url":"https://codeload.github.com/arifshariati/react-read-write-json/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arifshariati%2Freact-read-write-json/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31670383,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-10T17:19:37.612Z","status":"online","status_checked_at":"2026-04-11T02:00:05.776Z","response_time":54,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["express","file-read-write","filesystem","json","material-ui","nodejs","reactjs"],"created_at":"2025-02-21T15:39:56.887Z","updated_at":"2026-04-11T06:02:42.360Z","avatar_url":"https://github.com/arifshariati.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# react-read-write-JSON\n\nTimes in come in handdy in react Js applications where configuration setting from react js front end components needs to be persistent with json files rather persistent with database like mongo to reduce number of transactions.\n\nHowever, react js directly can not handle file system functionaly, for which Node js express comes in handy, where simple route for reading and wrting json files and do the job.\n\n[Checkout DEMO](https://react-read-write-json.netlify.app/)\n## Folder structure\nfor this sake of this example, we have kept out setting folder outside our backend project;\n\n```\nconst default_path = `${path.join(__dirname, '../../setting')}/`;\n```\n\n## Module - reading and wrting JSON files\n\nThis is the core module for reading and writing JSON files in setting folder. \n\n```\nconst fs = require('fs');\nconst path = require('path');\n\nconst default_path = `${path.join(__dirname, '../../setting')}/`;\n\nmodule.exports = {\n\n    fileExists : (fileName) =\u003e {\n        return new Promise((resolve) =\u003e {\n            fs.access(`${default_path}${fileName}`,fs.F_OK,(error) =\u003e {\n                error ? resolve(false) : resolve(true);\n            });\n        });\n    },\n    readJSON : (fileName, cb) =\u003e {\n\n        fs.readFile(`${default_path}${fileName}`, (err, fileData) =\u003e {\n    \n            if (err) {\n                return cb \u0026\u0026 cb(err)\n            }\n            try {\n                const object = JSON.parse(fileData);\n                \n                return cb \u0026\u0026 cb(null, object);\n            } catch(err) {\n                return cb \u0026\u0026 cb(err)\n            }\n            \n        });\n    },\n    writeJSON: (fileName, data) =\u003e {\n        const jsonString = JSON.stringify(data,null,4);\n\n        return new Promise((resolve) =\u003e {\n            fs.writeFile(`${default_path}${fileName}`, jsonString, error =\u003e {\n                error ? resolve(false) : resolve(true);\n            });\n        });\n        \n    }\n};\n```\n\n## How to use ?\n\nclone project in your local machine, and get started checking out functionalities;\n\n```\nnpm start\n```\n\nCheers!","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farifshariati%2Freact-read-write-json","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farifshariati%2Freact-read-write-json","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farifshariati%2Freact-read-write-json/lists"}