
Product
Socket for Jira Is Now Available
Socket for Jira lets teams turn alerts into Jira tickets with manual creation, automated ticketing rules, and two-way sync.
@awsless/json
Advanced tools
The `@awsless/json` package adds support for more JavaScript native types to JSON.
The @awsless/json package adds support for more JavaScript native types to JSON.
JSON doesn't have support for types like:
undefinedSetMapDateBigIntBigFloat - npm package @awsless/bit-floatHaving to decode & encode these type of values can get quite annoying. We try to solve this problem by encoding these types using valid JSON syntax.
import { parse, stringify } from '@awsless/json';
// Stringify a bigint.
// The output will be {"$bigint":"1"}
const json = stringify(1n)
// Parse the json with a bigint inside.
const value = parse(json)
In some cases you might not have control over the JSON parser that is being used. In these cases your JSON will still be able to parse, but the output will be incorrect. We can patch the incorrect output by using the patch function.
import { stringify, patch } from '@awsless/json';
const json = stringify(1n)
// The native JSON.parse function will not parse our bigint correctly.
const broken = JSON.parse(json)
// Will fix the broken output.
const fixed = patch(broken)
We let you extend JSON to support your own custom types.
import { parse, stringify, Serializable } from '@awsless/json';
class Custom {
readonly value
constructor(value: string) {
this.value = value
}
}
const $custom: Serializable<Custom, string> = {
is: v => v instanceof Custom,
parse: v => new Custom(v),
stringify: v => v.value,
}
// Stringify your custom type.
const json = stringify(new Custom('example'), { $custom })
// Parse the json with your custom type.
const value = parse(json, { $custom })
We use the $ character to encode our special types inside JSON. In order to prevent parsing errors we recommend to avoid using the $ character inside your object property names.
undefined as value type will be stripped away.// Will result in an empty object.
const result = parse(stringify({ key: undefined }))
// Will log false.
console.log('key' in result)
// Will log true.
console.log(result.key === undefined)
FAQs
The `@awsless/json` package adds support for more JavaScript native types to JSON.
We found that @awsless/json demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers 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.

Product
Socket for Jira lets teams turn alerts into Jira tickets with manual creation, automated ticketing rules, and two-way sync.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.