
Security News
The Hidden Blast Radius of the Axios Compromise
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.
reflect2json
Advanced tools
A lib for reflecting class to json with decorator in .ts file.
npm i reflect2json
yarn add reflect2json
emitDecoratorMetadata and experimentalDecorators in tsconfig.json{
"compilerOptions": {
"...otherCompilerOptions": "...",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"...otherCompilerOptions": "..."
}
}
import { jsonFormat, jsonIgnore, jsonPick, jsonReflect } from "reflect2json";
// use 'reflect2json/lib/src/reflect2json' instead when import failed!
@jsonReflect() // <-- Decorator jsonReflect, it will rewrite this.toJSON for reflcting
export class Example {
private _name: string = "example"; // <-- it will be ignored automanic when property key starts with '_'
public get name(): string { // <-- notice: getter property will position to the end of json
return this._name;
}
public set name(value: string) {
this._name = value;
}
@jsonIgnore() // <-- ignore property to json
public noSerialize = "no!!!";
@jsonIgnore((value: string) => value.toUpperCase() === "A") // <-- only ignore when value is A or a (only ignore when predicate = true)
public ignoreA = "A";
@jsonFormat((value: string) => value.toUpperCase()) // <-- format value to json
public formatString = "my name is linwrui";
@jsonPick("a", "b", "c") // <-- pick keys to json
public pickABC = {
a: "1",
b: "2",
c: "3",
d: "noPick",
e: "noPick",
};
}
const example = new Example();
console.log(JSON.stringify(example)); // <-- '{"formatString":"MY NAME IS LINWRUI","pickABC":{"a":"1","b":"2","c":"3"},"name":"example"}'
Thanks for using!
FAQs
A lib for reflecting class to json with decorator in `.ts file`.
We found that reflect2json 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
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.

Research
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.

Research
Malicious versions of the Telnyx Python SDK on PyPI delivered credential-stealing malware via a multi-stage supply chain attack.