Skip to content

tiaanduplessis/json-reader-writer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

📘 json-reader-writer ✍️

Read or write to a JSON file synchronously


Table of Contents

Table of Contents
  • Install
  • Usage
  • API
  • Contribute
  • License
  • Install

    Note that this module Uses JSON.stringify, which can run out of memory. If the data you need to write is large, consider using a streaming JSON writer, such as @mbostock's json-write. Otherwise, go ahead and...

    $ npm install --save json-reader-writer
    $ yarn add json-reader-writer

    Usage

    const {readJSON, writeJson} = require('json-reader-writer')
    const filePath = 'foo.json'
    const obj = {
      foo: 1,
      bar: 2,
      baz: 2
    }
    
    console.log(writeJson(filePath, obj)) // true if successful
    console.log(readJSON(filePath)) // { foo: 1, bar: 2, baz: 2 }

    API

    readJSON(filename)

    Takes the filename of the JSON file you want to read from as argument. Defaults to file.json if no filename provided.

    writeJSON(filename, objectToWrite)

    Takes the filename of the JSON file you want to write to and the valid object you want to write as arguments.

    Contribute

    Contributions are welcome. Please open up an issue or create PR if you would like to help out.

    Note: If editing the README, please conform to the standard-readme specification.

    License

    Licensed under the MIT License.

    About

    Read or write to a JSON file synchronously

    Topics

    Resources

    License

    Stars

    Watchers

    Forks

    Packages

    No packages published