2.0.1 • Published 2 years ago

f2json v2.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

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

ParamTypeDescription
dirnameStringOptional,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

ParamType
pathString
jsonObject

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

ParamType
pathString
encodingString

f2Json.clear(path_)

Type an empty json object into the specified file

Kind: instance method of F2Json

ParamType
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.

2.0.1

2 years ago

2.0.0

2 years ago

1.1.0

2 years ago

1.0.0

2 years ago