
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
json-transients
Advanced tools
A simple and minimalist wrapper library to deal with JavaScript object to JSON transformations and remove transient fields.
A simple and minimalist wrapper library to deal with JavaScript object to JSON transformations that supports removing transient fields.
Install via npm
npm install json-transients
or yarn
yarn add json-transients
Let's take a very simple JSON object as example ...
const json = {
$_transient: '',
isUndefined: undefined,
str: "string",
number: 1,
bool: true,
fn: () => { }
}
... and transform it to remove transient fiels (properties prefixed with $_ in this example)
const JsonTransients = require('json-transients')
const jst = new JsonTransients()
const result = jst.transform(json)
This will remove all transient fields and return a valid JSON object:
{
isUndefined: null,
str: "string",
number: 1,
bool: true
}
Each instance of JsonTransients takes a configuration object with following properties:
| Property | Required | Default | Description |
|---|---|---|---|
prefix | no | $_ | Prefix for transients fields that are being removed |
transformUndefined | no | true | Sets all undefined properties to null. If set to false all undefined properties will be removed. You can also define a custom handler. |
transformDate | no | toISOString() | Define a custom handler to transfrom Date objects. Sets all date properties to ISO string by default. |
const jst = new JsonTransients({
// use a custom prefix
prefix: 'CUSTOM_`,
// transform all undefined properties to "not_defined" string
transformUndefined: () => {
return 'not_defined'
},
// transform all dates to timestamp
transformDate: (value) => {
return value.getTime()
}
})
This project is licensed under the MIT license, Copyright (c) 2020 David Pichsenmeister | pichsenmeister.com. For more information see LICENSE.
FAQs
A simple and minimalist wrapper library to deal with JavaScript object to JSON transformations and remove transient fields.
We found that json-transients 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
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.