json_functions
v1.0.5
Published
read ,overwrite/create ,and append to json file with easy function and tepmlate
Downloads
3
Maintainers
Readme
JSON Functions that :
Installation
npm install json_functions
or simpler
npm i json_functions
Why should I use this package?
This package samples many things as:
- just writing the name of the json
read("jsonExample")
and it reads all the JSON in one command.
- Creating new JSON with an easy template
write(jsonName,id,firstname,lastname,address)
That gives a nice template with an array
[
id,{
"First name":firstname,
"Last name":lastname,
"Address":address
}]
Attention: write
function will overwrite the JSON file. be careful with the JSONs you are writing on.
- append a new line into the JSON array with an easy template
append(jsonName,id,firstname,lastname,address)
That gives nice template with array
[
id,{
"First name":firstname,
"Last name":lastname,
"Address":address
}]
Also, this function checks if there is the same id as your input and if the id is already there raises an error.
Attention: append
function will not append into an empty JSON and won't create a new one.
Usage
const jf = require('json_functions');
Examples:
input:
jf.write(jsonName,id,firstname,lastname,address)
output: in the json:
[
[id,{
"First name":firstname,
"Last name":lastname,
"Address":address
}]]
input:
jf.append(jsonName,id,firstname,lastname,address)
output: in the json:
[[id,{
"First name":firstname,
"Last name":lastname,
"Address":address
}] ,
[id,{
"First name":firstname,
"Last name":lastname,
"Address":address
}]]
jf.read(jsonName)