JSON Porter
Export any JavaScript object as a JSON file download or upload a JSON file to import a JavaScript object. This is intended to be used within the context of a web browser, not within node.js since there are much better ways to do this in node.
Getting Started
npm install --save json-porter
Example Usage
JavaScript
var JsonPorter = default; // Import library let obj = ; // Have an objectobjname = 'Object';objdesc = 'Hello World';objtags = 'JavaScript' 'Download' 'Upload' ; var jp = ; // Instantiate json-porter jp; // Download JSON file var obj2; jp;
TypeScript
; // Import library ; // Have an objectobj.name = 'Object';obj.desc = 'Hello World';obj.tags = ; ; // Instantiate json-porter jp.exportobj, 'MyObjectFilename.json'; // Download JSON file ; // Open file dialog and upload a file // to receive parsed JSON object
JSON File
This example would produce a JSON file with these contents which you could then import the file to reconstitute a clone of the original object.
MyObjectFilename.json
Building the code
# download & install dependencies npm install # Transpiles TypeScript, generates source map files & TypeScript type declaration files npm run build # Deletes all build output npm run clean
Who is Jason Porter? -My wife