
Company News
/Security News
Socket Selected for OpenAI's Cybersecurity Grant Program
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.
$ npm install xson
var xson = require('xson');
xson.parse(string [, options])Parse an XSON string and return the result. Valid options keys:
constructors: a map of object type names to their constructor functions. Whenever the XSON parser encounters a named object (or indeed a vector or money), the corresponding constructor will be called receiving the object's properties as a parameter. For example, to handle the following XSON:
Person(name: "Jason")
one would call parse in the following manner:
```
xson.parse('Person(name: "Jason")', {
constructors: {
Person: function(props) {
return new PersonModel(props.name);
}
}
});
```
Note that despite the name "constructors", such functions are invoked by regular function calls, i.e. `Person(props)` and not `new Person(props)`.
xson.stringify(object, [, options])Convert an object structure to an XSON string and return it. Valid options keys:
toStructure: a function that is called whenever the serializer encounters a Javascript object type (excluding null and arrays) to determine how it should be encoded. Returns one of the following:
['money', major, minor, currency]. Major/minor should be integers and currency is an optional string.['vec2', x, y] or ['vec3', x, y, z].['ConstructorName', properties].null. XSON will then serialize the object as a dictionary (i.e. standard JSON object).The default implementation of toStructure will detect XSON's built-in Money, Vec2 and Vec3 types and encode them accordingly. All other objects will be encoded as XSON dictionaries.
In addition to standard JSON syntax, on, off, yes and no are acceptable:
true
false
on
off
yes
no
Date are expressed in ISO-8601. When time is also present seconds and milliseconds may be omitted for convience's sake. When so omitted, they default to zero.
2014-03-07
2014-03-07T23:02
2014-03-07T23:02:28
2014-03-07T23:02:28.123
Standard integers and floats are supported:
128
12.3
In addition you may use hex and binary literals:
0xFF0F
0b11010111
Any numeric literals may increase readability by using _:
1_000_000
"this is a string"
As per JSON.
[]
[1, 2, 3]
[$3GBP, $10.75USD]
As per JSON objects. Quoting of keys is optional for simple identifiers.
{}
{foo: "bar"}
{"a key with spaces and punctuation!": false}
The money type is denoted by a $ prefix followed by decimal number and optional currency.
$2
$2.50
$2.50USD
Objects are represented by a named constructor followed by a parenthesized property list. The format of the property list is identical to that of a dictionary.
Person(name: "Jason", location: "Glasgow")
XSON supports 2- and 3- component numeric vectors:
<1,2>
<2.3,6.7,0>
FAQs
eXtended Serialized Object Notation
The npm package xson receives a total of 18 weekly downloads. As such, xson popularity was classified as not popular.
We found that xson 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.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.

Security News
Socket CEO Feross Aboukhadijeh joins 10 Minutes or Less, a podcast by Ali Rohde, to discuss the recent surge in open source supply chain attacks.

Research
/Security News
Campaign of 108 extensions harvests identities, steals sessions, and adds backdoors to browsers, all tied to the same C2 infrastructure.