
Security News
Axios Maintainer Confirms Social Engineering Attack Behind npm Compromise
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.
typescript-json-object-mapper
Advanced tools
This a simple package to mapping a json object.
npm install typescript-json-object-mapper
yarn add typescript-json-object-mapper
To work with decorators, you need first enable emitDecoratorMetadata y experimentalDecorators on you tsconfig.json.
Example:
{
"compilerOptions": {
"emitDecoratorMetadata": true,
"experimentalDecorators": true
}
}
This example tries to show all possible cases in which you might need to use this utility.
class UserView extends JsonView {
@JsonProperty
username: string;
@JsonProperty({
ignore: true
})
password: string;
@JsonProperty({
topic: 'custom'
})
birthday: string;
@JsonProperty({
topic: 'custom2'
})
phone: string;
}
const json = {
username: "annon",
password: "12345678",
birthday: "1992-03-20",
phone: "+0123456789"
};
const serialized = JsonObjectMapper.serialize(json, UserView).toString();
results:
{
username: "annon",
birthday: "1992-03-20",
phone: "+0123456789"
}
const serialized = JsonObjectMapper.serialize(json, UserView, ['custom']).toString();
results:
{
username: "annon",
birthday: "1992-03-20"
}
const serialized = JsonObjectMapper.serialize(json, UserView, ['custom', 'custom2']).toString();
results:
{
username: "annon",
birthday: "1992-03-20",
phone: "+0123456789"
}
Date.parseDateNumberNumberObject ArrayObjectStringObject, Constructor, Function, Date, ObjectId to String
toString method when it exists
toString return [object object], JsonObjectMapper will try iterate object to create a plain object with defualts values.This function always return Serialization object.
And can using it with data as Array or Object.
// from Array
JsonObjectMapper.serialize([
{
email: "john.smith@example.com",
password: "123456"
},
{
email: "john.smith@example.com",
password: "123456"
},
{
email: "john.smith@example.com",
password: "123456"
}
], UserView);
// from Object
JsonObjectMapper.serialize({
email: "john.smith@example.com",
password: "123456"
}, UserView);
spaces:number = 4): stringThis method return a string representation of object.
This method return a json object representation.
FAQs
Json Object mapper writing in TypeScript
The npm package typescript-json-object-mapper receives a total of 76 weekly downloads. As such, typescript-json-object-mapper popularity was classified as not popular.
We found that typescript-json-object-mapper 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
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.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.