Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
json-formater
Advanced tools
Node.js JSON data formater / comparator
Imagine:
You have stream where you recieve json data (e.g. twitter user/site stream) and you need save this data in DB, but before you save - you need classificate and format this data in your format.
or
You need validate json object (check whether properties exist and with correct values).
This module can do this.
npm install json-formater
var formater = require('json-formater');
//your skeleton
var expected_json = {
status: true,
data: {
person_name: '@ignore_value',
person_surname: '@ignore_value'
}
}
//e.g. data from some stream
var actual_json = {
status: true,
data: {
person_name: 'John',
person_surname: 'Formater'
}
}
//formatted object skeleton
var person = {
name: '["data"]["person_name"]',
surname: '["data"]["person_surname"]'
}
formater(expected_json, actual_json, person, function(match, person_obj) {
if (match) {
console.log(person_obj);
//output (formatted data): { name: 'John', surname: 'Formater' }
} else {
console.log('Person data not found in actual json object');
}
});
Params:
expected_json
: json skeleton who must coincide against actual_json (param is required)actual_json
: any json data (param is required)person
: formatted object skeleton (param is optional)Callback params:
match
:
true
: if expected_json
matches with actual_json
,false
: if don'tperson_obj
: formatted json object (only if formatted object skeleton was passed)@ignore_value
Write this flag (@ignore_value
) as expected object property if you not interested in object property data, but this property must exist / or you necessary these data set to "formatted" object.
name: '["data"]["person_name"]'
).FAQs
Node.js JSON data formater / comparator
The npm package json-formater receives a total of 9 weekly downloads. As such, json-formater popularity was classified as not popular.
We found that json-formater demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.