Skip to content

Changlon/f2json

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

f2json

NPM version Build Status Codecov GitHub issues GitHub license

Quickly create read-write json files f2json

  • Quick Import and write out the JSON data to the file
  • Introduce a Json file operation in your code using a relative path
  • You can use the created file as a temporary cache

Installation

npm

npm install f2json 

yarn

yarn add f2json 

API Reference

F2Json ⏏

Kind: Exported class

new F2Json([dirname])

Create f2Json

Param Type Description
[dirname] String Optional,You can also pass in a relative path such as __dirname in your code file

Example
Basic usage:

index.js :

var F2Json = require("f2json")  
var f2json = new F2Json()

f2json.json2file("./cache/user.json",[
     {name:"Changlon",age:22},
       ...
])

var {json} =  f2json.file2json("./cache/user.json") 

console.log(json) 

f2Json.getLastCallDirname() ⇒ String

Returns the file path that called this function

Kind: instance method of F2Json

f2Json.json2file(path, json)

Writes the json object as data to the specified fileWrites the json object as data to the specified file

Kind: instance method of F2Json

Param Type
path String
json Object

f2Json.file2json(path, encoding) ⇒ Object.<json, ok>

Read the file as a Json object in Json format

Kind: instance method of F2Json
Returns: Object.<json, ok> - returns data json and function ok When you call the OK function, the modified data json is saved to the corresponding file

Param Type
path String
encoding String

f2Json.clear(path_)

Type an empty json object into the specified file

Kind: instance method of F2Json

Param Type
path_ String

Contributing

Please submit all issues and pull requests to the Changlon/f2json repository!

Tests

Run tests using npm test.

Support

If you have any problem or suggestion please open an issue here.