Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions docs/06-concepts/03-serialization.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,25 @@ For most purposes, you will want to use Serverpod's native serialization. Howeve

1. Your objects must have a method called `toJson()` which returns a JSON serialization of the object.

```dart
Map<String, dynamic> toJson() {
return {
'name': 'John Doe',
};
}
```
```dart
Map<String, dynamic> toJson() {
return {
'name': 'John Doe',
};
}
```

2. There must be a constructor or factory called `fromJson()`, which takes a JSON serialization as parameters.

```dart
factory ClassName.fromJson(
Map<String, dynamic> json,
) {
return ClassName(
name: json['name'] as String,
);
}
```
```dart
factory ClassName.fromJson(
Map<String, dynamic> json,
) {
return ClassName(
name: json['name'] as String,
);
}
```

3. You must declare your custom serializable objects in the `config/generator.yaml` file in the server project, the path needs to be accessible from both the server package and the client package.

Expand Down
2 changes: 1 addition & 1 deletion docs/06-concepts/08-caching.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ Future<UserData> getUserData(Session session, int userId) async {
() async => UserData.db.findById(session, userId),
lifetime: Duration(minutes: 5),
),
);
);

Comment thread
marcelomendoncasoares marked this conversation as resolved.
// Return the user data to the client
return userData;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ For most purposes, you will want to use Serverpod's native serialization. Howeve
```dart
Map<String, dynamic> toJson() {
return {
name: 'John Doe',
'name': 'John Doe',
};
}
```
Expand Down
12 changes: 6 additions & 6 deletions versioned_docs/version-2.0.0/05-concepts/03-serialization.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@ For most purposes, you will want to use Serverpod's native serialization. Howeve

```dart
Map<String, dynamic> toJson() {
return {
name: 'John Doe',
};
return {
'name': 'John Doe',
};
}
Comment thread
Swiftaxe marked this conversation as resolved.
```

2. There must be a constructor or factory called `fromJson()`, which takes a JSON serialization as parameters.

```dart
factory ClassName.fromJson(
Map<String, dynamic> json,
Map<String, dynamic> json,
) {
return ClassName(
return ClassName(
name: json['name'] as String,
);
);
}
```

Expand Down
12 changes: 6 additions & 6 deletions versioned_docs/version-2.1.0/06-concepts/03-serialization.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@ For most purposes, you will want to use Serverpod's native serialization. Howeve

```dart
Map<String, dynamic> toJson() {
return {
name: 'John Doe',
};
return {
'name': 'John Doe',
};
}
```

2. There must be a constructor or factory called `fromJson()`, which takes a JSON serialization as parameters.

```dart
factory ClassName.fromJson(
Map<String, dynamic> json,
Map<String, dynamic> json,
) {
return ClassName(
return ClassName(
name: json['name'] as String,
);
);
}
```

Expand Down
2 changes: 1 addition & 1 deletion versioned_docs/version-2.1.0/06-concepts/08-caching.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Future<UserData> getUserData(Session session, int userId) async {
() async => UserData.db.findById(session, userId),
lifetime: Duration(minutes: 5),
),
);
);

// Return the user data to the client
return userData;
Expand Down
12 changes: 6 additions & 6 deletions versioned_docs/version-2.2.0/06-concepts/03-serialization.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@ For most purposes, you will want to use Serverpod's native serialization. Howeve

```dart
Map<String, dynamic> toJson() {
return {
name: 'John Doe',
};
return {
'name': 'John Doe',
};
}
```

2. There must be a constructor or factory called `fromJson()`, which takes a JSON serialization as parameters.

```dart
factory ClassName.fromJson(
Map<String, dynamic> json,
Map<String, dynamic> json,
) {
return ClassName(
return ClassName(
name: json['name'] as String,
);
);
}
```

Expand Down
2 changes: 1 addition & 1 deletion versioned_docs/version-2.2.0/06-concepts/08-caching.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Future<UserData> getUserData(Session session, int userId) async {
() async => UserData.db.findById(session, userId),
lifetime: Duration(minutes: 5),
),
);
);

// Return the user data to the client
return userData;
Expand Down
12 changes: 6 additions & 6 deletions versioned_docs/version-2.3.0/06-concepts/03-serialization.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@ For most purposes, you will want to use Serverpod's native serialization. Howeve

```dart
Map<String, dynamic> toJson() {
return {
name: 'John Doe',
};
return {
'name': 'John Doe',
};
}
```

2. There must be a constructor or factory called `fromJson()`, which takes a JSON serialization as parameters.

```dart
factory ClassName.fromJson(
Map<String, dynamic> json,
Map<String, dynamic> json,
) {
return ClassName(
return ClassName(
name: json['name'] as String,
);
);
}
```

Expand Down
2 changes: 1 addition & 1 deletion versioned_docs/version-2.3.0/06-concepts/08-caching.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Future<UserData> getUserData(Session session, int userId) async {
() async => UserData.db.findById(session, userId),
lifetime: Duration(minutes: 5),
),
);
);

// Return the user data to the client
return userData;
Expand Down
12 changes: 6 additions & 6 deletions versioned_docs/version-2.4.0/06-concepts/03-serialization.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@ For most purposes, you will want to use Serverpod's native serialization. Howeve

```dart
Map<String, dynamic> toJson() {
return {
name: 'John Doe',
};
return {
'name': 'John Doe',
};
}
```

2. There must be a constructor or factory called `fromJson()`, which takes a JSON serialization as parameters.

```dart
factory ClassName.fromJson(
Map<String, dynamic> json,
Map<String, dynamic> json,
) {
return ClassName(
return ClassName(
name: json['name'] as String,
);
);
}
```

Expand Down
2 changes: 1 addition & 1 deletion versioned_docs/version-2.4.0/06-concepts/08-caching.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Future<UserData> getUserData(Session session, int userId) async {
() async => UserData.db.findById(session, userId),
lifetime: Duration(minutes: 5),
),
);
);

// Return the user data to the client
return userData;
Expand Down
12 changes: 6 additions & 6 deletions versioned_docs/version-2.5.0/06-concepts/03-serialization.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@ For most purposes, you will want to use Serverpod's native serialization. Howeve

```dart
Map<String, dynamic> toJson() {
return {
name: 'John Doe',
};
return {
'name': 'John Doe',
};
}
```

2. There must be a constructor or factory called `fromJson()`, which takes a JSON serialization as parameters.

```dart
factory ClassName.fromJson(
Map<String, dynamic> json,
Map<String, dynamic> json,
) {
return ClassName(
return ClassName(
name: json['name'] as String,
);
);
}
```

Expand Down
2 changes: 1 addition & 1 deletion versioned_docs/version-2.5.0/06-concepts/08-caching.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Future<UserData> getUserData(Session session, int userId) async {
() async => UserData.db.findById(session, userId),
lifetime: Duration(minutes: 5),
),
);
);

// Return the user data to the client
return userData;
Expand Down
12 changes: 6 additions & 6 deletions versioned_docs/version-2.6.0/06-concepts/03-serialization.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@ For most purposes, you will want to use Serverpod's native serialization. Howeve

```dart
Map<String, dynamic> toJson() {
return {
name: 'John Doe',
};
return {
'name': 'John Doe',
};
}
```

2. There must be a constructor or factory called `fromJson()`, which takes a JSON serialization as parameters.

```dart
factory ClassName.fromJson(
Map<String, dynamic> json,
Map<String, dynamic> json,
) {
return ClassName(
return ClassName(
name: json['name'] as String,
);
);
}
```

Expand Down
2 changes: 1 addition & 1 deletion versioned_docs/version-2.6.0/06-concepts/08-caching.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Future<UserData> getUserData(Session session, int userId) async {
() async => UserData.db.findById(session, userId),
lifetime: Duration(minutes: 5),
),
);
);

// Return the user data to the client
return userData;
Expand Down
12 changes: 6 additions & 6 deletions versioned_docs/version-2.7.0/06-concepts/03-serialization.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@ For most purposes, you will want to use Serverpod's native serialization. Howeve

```dart
Map<String, dynamic> toJson() {
return {
name: 'John Doe',
};
return {
'name': 'John Doe',
};
}
```

2. There must be a constructor or factory called `fromJson()`, which takes a JSON serialization as parameters.

```dart
factory ClassName.fromJson(
Map<String, dynamic> json,
Map<String, dynamic> json,
) {
return ClassName(
return ClassName(
name: json['name'] as String,
);
);
}
```

Expand Down
2 changes: 1 addition & 1 deletion versioned_docs/version-2.7.0/06-concepts/08-caching.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Future<UserData> getUserData(Session session, int userId) async {
() async => UserData.db.findById(session, userId),
lifetime: Duration(minutes: 5),
),
);
);

// Return the user data to the client
return userData;
Expand Down
12 changes: 6 additions & 6 deletions versioned_docs/version-2.8.0/06-concepts/03-serialization.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@ For most purposes, you will want to use Serverpod's native serialization. Howeve

```dart
Map<String, dynamic> toJson() {
return {
name: 'John Doe',
};
return {
'name': 'John Doe',
};
}
```

2. There must be a constructor or factory called `fromJson()`, which takes a JSON serialization as parameters.

```dart
factory ClassName.fromJson(
Map<String, dynamic> json,
Map<String, dynamic> json,
) {
return ClassName(
return ClassName(
name: json['name'] as String,
);
);
}
```

Expand Down
2 changes: 1 addition & 1 deletion versioned_docs/version-2.8.0/06-concepts/08-caching.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Future<UserData> getUserData(Session session, int userId) async {
() async => UserData.db.findById(session, userId),
lifetime: Duration(minutes: 5),
),
);
);

// Return the user data to the client
return userData;
Expand Down
Loading
Loading