From 6e8b9af242d16aa373966ad6be506dbd8cf45cd9 Mon Sep 17 00:00:00 2001 From: Davide Caroselli Date: Sat, 20 Apr 2024 13:31:09 +0200 Subject: [PATCH] Remove @Json decorator from documentation --- README.md | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/README.md b/README.md index 21b8dee..94e7c9e 100644 --- a/README.md +++ b/README.md @@ -44,9 +44,8 @@ for your data management needs. Explore the [Sequelize support](#sequelize-suppo Getting started with Jsonthis is quick and straightforward. Here's a simple example to get you going: ```typescript -import {Json, JsonField, Jsonthis} from "jsonthis"; +import {JsonField, Jsonthis} from "jsonthis"; -@Json class User { id: number; email: string; @@ -78,7 +77,6 @@ You can achieve this by passing `false` to the `@JsonField` decorator directly or by using the `JsonFieldOptions` object: ```typescript -@Json class User { // ... @JsonField({visible: false}) // This has the same effect as @JsonField(false) @@ -99,7 +97,6 @@ function showEmailOnlyToOwner(/* email */_: string, state: JsonTraversalState, o return opts?.context?.callerId === (state.parent as User)?.id; } -@Json class User { id: number; @JsonField({visible: showEmailOnlyToOwner}) @@ -145,7 +142,6 @@ By default, Jsonthis uses whatever casing you use in your TypeScript code, but you can change it to `camelCase`, `snake_case`, or `PascalCase`: ```typescript -@Json class User { id: number = 123; user_name: string = "john-doe"; @@ -177,7 +173,6 @@ function dateSerializer(value: Date): string { return value.toUTCString(); } -@Json class User { id: number = 1; registeredAt: Date = new Date(); @@ -200,7 +195,6 @@ function maskEmail(value: string): string { return value.replace(/(?<=.).(?=[^@]*?.@)/g, "*"); } -@Json class User { id: number = 1; @JsonField({serializer: maskEmail}) @@ -223,7 +217,6 @@ function maskEmail(value: string, state: JsonTraversalState, opts?: ToJsonOption return value.replace(/(?<=.).(?=[^@]*?.@)/g, opts?.context?.maskChar || "*"); } -@Json class User { id: number = 1; @JsonField({serializer: maskEmail}) @@ -246,7 +239,6 @@ function serializeCircularReference(value: any): any { return { $ref: `$${value.constructor.name}(${value.id})` }; } -@Json class User { id: number; name: string;