
Security News
Open VSX Begins Implementing Pre-Publish Security Checks After Repeated Supply Chain Incidents
Following multiple malicious extension incidents, Open VSX outlines new safeguards designed to catch risky uploads earlier.
Serialize and deserialize Javascript objects into JSON
It will stringify and parse these values (which JSON.stringify and JSON.parse will not):
If any core javascript objects are missing, please submit an issue or pull request
var obj = {
a: NaN,
b: Infinity,
c: /[abc]+def/gi
};
var objStr = jsoni.stringify(obj);
/*
'{
"a": "NaN",
"b": "Infinity",
"c": {
"constructName": "RegExp",
"data": {
"source": "[abc]+def",
"flags": "gi"
}
}
}'
*/
var objB = jsoni.parse(objStr);
// objB.c is a regular expression clone of obj.c
objB.c.toString();
// '/[abc]+def/gi'
objB.c.test('aaabbbcccdef');
// true
npm install jsoni
none
same as JSON.stringify
same as JSON.parse
registers a constructor to serialize and deserialize
var jsoni = require('jsoni');
function Person(name, age) {
this.name = name;
this.age = age;
}
Person.prototype.greet = function () {
return 'hello, my name is ' + this.name + ' and I am ' + this.age + ' years old';
};
jsoni.register('Person', Person, {
serialize: function (person) {
return {
name: person.name,
age: person.age
};
},
deserialize: function (obj) {
return new Person(obj.name, obj.age);
}
});
var me = new Person('Jayce', 22);
var str = jsoni.stringify(me);
// '{"constructName":"Person","data":{"name":"Jayce","age":22}}'
var newMe = jsoni.parse(str);
newMe.greet();
// 'hello, my name is Jayce and I am 22 years old'
If a constructor's prototype has a toJSON method, then serialize does not need to be specified.
serialize will take precedence over toJSON if it is specified. If neither are specified, then the
default behavior of JSON.stringify is used.
If a constructor has a fromJSON method (ex: Person.fromJSON, not Person.prototype.fromJSON), then
deserialize does not need to be specified. deserialize will take precedence over fromJSON if it
is specified. If neither are specified, then the json data will be passed directly into the constructor
(new Constructor(data)).
unregister a constructor from jsoni
undefined connot be stringified or parsedFAQs
Serialize and deserialize Javascript objects into JSON
The npm package jsoni receives a total of 1 weekly downloads. As such, jsoni popularity was classified as not popular.
We found that jsoni 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
Following multiple malicious extension incidents, Open VSX outlines new safeguards designed to catch risky uploads earlier.

Research
/Security News
Threat actors compromised four oorzc Open VSX extensions with more than 22,000 downloads, pushing malicious versions that install a staged loader, evade Russian-locale systems, pull C2 from Solana memos, and steal macOS credentials and wallets.

Security News
Lodash 4.17.23 marks a security reset, with maintainers rebuilding governance and infrastructure to support long-term, sustainable maintenance.