diff --git a/docs/06-concepts/03-serialization.md b/docs/06-concepts/03-serialization.md index 29418347..486babc7 100644 --- a/docs/06-concepts/03-serialization.md +++ b/docs/06-concepts/03-serialization.md @@ -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 toJson() { - return { - 'name': 'John Doe', - }; - } - ``` + ```dart + Map 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 json, - ) { - return ClassName( - name: json['name'] as String, - ); - } - ``` + ```dart + factory ClassName.fromJson( + Map 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. diff --git a/docs/06-concepts/08-caching.md b/docs/06-concepts/08-caching.md index 89c3ffff..37be9a81 100644 --- a/docs/06-concepts/08-caching.md +++ b/docs/06-concepts/08-caching.md @@ -87,7 +87,7 @@ Future 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; diff --git a/versioned_docs/version-1.2.0/05-concepts/03-serialization.md b/versioned_docs/version-1.2.0/05-concepts/03-serialization.md index b4e07d9a..7ba13eed 100644 --- a/versioned_docs/version-1.2.0/05-concepts/03-serialization.md +++ b/versioned_docs/version-1.2.0/05-concepts/03-serialization.md @@ -7,7 +7,7 @@ For most purposes, you will want to use Serverpod's native serialization. Howeve ```dart Map toJson() { return { - name: 'John Doe', + 'name': 'John Doe', }; } ``` diff --git a/versioned_docs/version-2.0.0/05-concepts/03-serialization.md b/versioned_docs/version-2.0.0/05-concepts/03-serialization.md index 94cd0809..5462c604 100644 --- a/versioned_docs/version-2.0.0/05-concepts/03-serialization.md +++ b/versioned_docs/version-2.0.0/05-concepts/03-serialization.md @@ -6,9 +6,9 @@ For most purposes, you will want to use Serverpod's native serialization. Howeve ```dart Map toJson() { - return { - name: 'John Doe', - }; + return { + 'name': 'John Doe', + }; } ``` @@ -16,11 +16,11 @@ For most purposes, you will want to use Serverpod's native serialization. Howeve ```dart factory ClassName.fromJson( - Map json, + Map json, ) { - return ClassName( + return ClassName( name: json['name'] as String, - ); + ); } ``` diff --git a/versioned_docs/version-2.1.0/06-concepts/03-serialization.md b/versioned_docs/version-2.1.0/06-concepts/03-serialization.md index 438af210..25abdc3f 100644 --- a/versioned_docs/version-2.1.0/06-concepts/03-serialization.md +++ b/versioned_docs/version-2.1.0/06-concepts/03-serialization.md @@ -6,9 +6,9 @@ For most purposes, you will want to use Serverpod's native serialization. Howeve ```dart Map toJson() { - return { - name: 'John Doe', - }; + return { + 'name': 'John Doe', + }; } ``` @@ -16,11 +16,11 @@ For most purposes, you will want to use Serverpod's native serialization. Howeve ```dart factory ClassName.fromJson( - Map json, + Map json, ) { - return ClassName( + return ClassName( name: json['name'] as String, - ); + ); } ``` diff --git a/versioned_docs/version-2.1.0/06-concepts/08-caching.md b/versioned_docs/version-2.1.0/06-concepts/08-caching.md index 2fe38e6d..4bd584a4 100644 --- a/versioned_docs/version-2.1.0/06-concepts/08-caching.md +++ b/versioned_docs/version-2.1.0/06-concepts/08-caching.md @@ -48,7 +48,7 @@ Future 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; diff --git a/versioned_docs/version-2.2.0/06-concepts/03-serialization.md b/versioned_docs/version-2.2.0/06-concepts/03-serialization.md index 438af210..25abdc3f 100644 --- a/versioned_docs/version-2.2.0/06-concepts/03-serialization.md +++ b/versioned_docs/version-2.2.0/06-concepts/03-serialization.md @@ -6,9 +6,9 @@ For most purposes, you will want to use Serverpod's native serialization. Howeve ```dart Map toJson() { - return { - name: 'John Doe', - }; + return { + 'name': 'John Doe', + }; } ``` @@ -16,11 +16,11 @@ For most purposes, you will want to use Serverpod's native serialization. Howeve ```dart factory ClassName.fromJson( - Map json, + Map json, ) { - return ClassName( + return ClassName( name: json['name'] as String, - ); + ); } ``` diff --git a/versioned_docs/version-2.2.0/06-concepts/08-caching.md b/versioned_docs/version-2.2.0/06-concepts/08-caching.md index 2fe38e6d..4bd584a4 100644 --- a/versioned_docs/version-2.2.0/06-concepts/08-caching.md +++ b/versioned_docs/version-2.2.0/06-concepts/08-caching.md @@ -48,7 +48,7 @@ Future 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; diff --git a/versioned_docs/version-2.3.0/06-concepts/03-serialization.md b/versioned_docs/version-2.3.0/06-concepts/03-serialization.md index 438af210..25abdc3f 100644 --- a/versioned_docs/version-2.3.0/06-concepts/03-serialization.md +++ b/versioned_docs/version-2.3.0/06-concepts/03-serialization.md @@ -6,9 +6,9 @@ For most purposes, you will want to use Serverpod's native serialization. Howeve ```dart Map toJson() { - return { - name: 'John Doe', - }; + return { + 'name': 'John Doe', + }; } ``` @@ -16,11 +16,11 @@ For most purposes, you will want to use Serverpod's native serialization. Howeve ```dart factory ClassName.fromJson( - Map json, + Map json, ) { - return ClassName( + return ClassName( name: json['name'] as String, - ); + ); } ``` diff --git a/versioned_docs/version-2.3.0/06-concepts/08-caching.md b/versioned_docs/version-2.3.0/06-concepts/08-caching.md index 2fe38e6d..4bd584a4 100644 --- a/versioned_docs/version-2.3.0/06-concepts/08-caching.md +++ b/versioned_docs/version-2.3.0/06-concepts/08-caching.md @@ -48,7 +48,7 @@ Future 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; diff --git a/versioned_docs/version-2.4.0/06-concepts/03-serialization.md b/versioned_docs/version-2.4.0/06-concepts/03-serialization.md index 438af210..25abdc3f 100644 --- a/versioned_docs/version-2.4.0/06-concepts/03-serialization.md +++ b/versioned_docs/version-2.4.0/06-concepts/03-serialization.md @@ -6,9 +6,9 @@ For most purposes, you will want to use Serverpod's native serialization. Howeve ```dart Map toJson() { - return { - name: 'John Doe', - }; + return { + 'name': 'John Doe', + }; } ``` @@ -16,11 +16,11 @@ For most purposes, you will want to use Serverpod's native serialization. Howeve ```dart factory ClassName.fromJson( - Map json, + Map json, ) { - return ClassName( + return ClassName( name: json['name'] as String, - ); + ); } ``` diff --git a/versioned_docs/version-2.4.0/06-concepts/08-caching.md b/versioned_docs/version-2.4.0/06-concepts/08-caching.md index 2fe38e6d..4bd584a4 100644 --- a/versioned_docs/version-2.4.0/06-concepts/08-caching.md +++ b/versioned_docs/version-2.4.0/06-concepts/08-caching.md @@ -48,7 +48,7 @@ Future 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; diff --git a/versioned_docs/version-2.5.0/06-concepts/03-serialization.md b/versioned_docs/version-2.5.0/06-concepts/03-serialization.md index 438af210..25abdc3f 100644 --- a/versioned_docs/version-2.5.0/06-concepts/03-serialization.md +++ b/versioned_docs/version-2.5.0/06-concepts/03-serialization.md @@ -6,9 +6,9 @@ For most purposes, you will want to use Serverpod's native serialization. Howeve ```dart Map toJson() { - return { - name: 'John Doe', - }; + return { + 'name': 'John Doe', + }; } ``` @@ -16,11 +16,11 @@ For most purposes, you will want to use Serverpod's native serialization. Howeve ```dart factory ClassName.fromJson( - Map json, + Map json, ) { - return ClassName( + return ClassName( name: json['name'] as String, - ); + ); } ``` diff --git a/versioned_docs/version-2.5.0/06-concepts/08-caching.md b/versioned_docs/version-2.5.0/06-concepts/08-caching.md index 2fe38e6d..4bd584a4 100644 --- a/versioned_docs/version-2.5.0/06-concepts/08-caching.md +++ b/versioned_docs/version-2.5.0/06-concepts/08-caching.md @@ -48,7 +48,7 @@ Future 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; diff --git a/versioned_docs/version-2.6.0/06-concepts/03-serialization.md b/versioned_docs/version-2.6.0/06-concepts/03-serialization.md index 438af210..25abdc3f 100644 --- a/versioned_docs/version-2.6.0/06-concepts/03-serialization.md +++ b/versioned_docs/version-2.6.0/06-concepts/03-serialization.md @@ -6,9 +6,9 @@ For most purposes, you will want to use Serverpod's native serialization. Howeve ```dart Map toJson() { - return { - name: 'John Doe', - }; + return { + 'name': 'John Doe', + }; } ``` @@ -16,11 +16,11 @@ For most purposes, you will want to use Serverpod's native serialization. Howeve ```dart factory ClassName.fromJson( - Map json, + Map json, ) { - return ClassName( + return ClassName( name: json['name'] as String, - ); + ); } ``` diff --git a/versioned_docs/version-2.6.0/06-concepts/08-caching.md b/versioned_docs/version-2.6.0/06-concepts/08-caching.md index 2fe38e6d..4bd584a4 100644 --- a/versioned_docs/version-2.6.0/06-concepts/08-caching.md +++ b/versioned_docs/version-2.6.0/06-concepts/08-caching.md @@ -48,7 +48,7 @@ Future 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; diff --git a/versioned_docs/version-2.7.0/06-concepts/03-serialization.md b/versioned_docs/version-2.7.0/06-concepts/03-serialization.md index 438af210..25abdc3f 100644 --- a/versioned_docs/version-2.7.0/06-concepts/03-serialization.md +++ b/versioned_docs/version-2.7.0/06-concepts/03-serialization.md @@ -6,9 +6,9 @@ For most purposes, you will want to use Serverpod's native serialization. Howeve ```dart Map toJson() { - return { - name: 'John Doe', - }; + return { + 'name': 'John Doe', + }; } ``` @@ -16,11 +16,11 @@ For most purposes, you will want to use Serverpod's native serialization. Howeve ```dart factory ClassName.fromJson( - Map json, + Map json, ) { - return ClassName( + return ClassName( name: json['name'] as String, - ); + ); } ``` diff --git a/versioned_docs/version-2.7.0/06-concepts/08-caching.md b/versioned_docs/version-2.7.0/06-concepts/08-caching.md index 2fe38e6d..4bd584a4 100644 --- a/versioned_docs/version-2.7.0/06-concepts/08-caching.md +++ b/versioned_docs/version-2.7.0/06-concepts/08-caching.md @@ -48,7 +48,7 @@ Future 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; diff --git a/versioned_docs/version-2.8.0/06-concepts/03-serialization.md b/versioned_docs/version-2.8.0/06-concepts/03-serialization.md index 438af210..25abdc3f 100644 --- a/versioned_docs/version-2.8.0/06-concepts/03-serialization.md +++ b/versioned_docs/version-2.8.0/06-concepts/03-serialization.md @@ -6,9 +6,9 @@ For most purposes, you will want to use Serverpod's native serialization. Howeve ```dart Map toJson() { - return { - name: 'John Doe', - }; + return { + 'name': 'John Doe', + }; } ``` @@ -16,11 +16,11 @@ For most purposes, you will want to use Serverpod's native serialization. Howeve ```dart factory ClassName.fromJson( - Map json, + Map json, ) { - return ClassName( + return ClassName( name: json['name'] as String, - ); + ); } ``` diff --git a/versioned_docs/version-2.8.0/06-concepts/08-caching.md b/versioned_docs/version-2.8.0/06-concepts/08-caching.md index 2fe38e6d..4bd584a4 100644 --- a/versioned_docs/version-2.8.0/06-concepts/08-caching.md +++ b/versioned_docs/version-2.8.0/06-concepts/08-caching.md @@ -48,7 +48,7 @@ Future 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; diff --git a/versioned_docs/version-2.9.0/06-concepts/03-serialization.md b/versioned_docs/version-2.9.0/06-concepts/03-serialization.md index 438af210..25abdc3f 100644 --- a/versioned_docs/version-2.9.0/06-concepts/03-serialization.md +++ b/versioned_docs/version-2.9.0/06-concepts/03-serialization.md @@ -6,9 +6,9 @@ For most purposes, you will want to use Serverpod's native serialization. Howeve ```dart Map toJson() { - return { - name: 'John Doe', - }; + return { + 'name': 'John Doe', + }; } ``` @@ -16,11 +16,11 @@ For most purposes, you will want to use Serverpod's native serialization. Howeve ```dart factory ClassName.fromJson( - Map json, + Map json, ) { - return ClassName( + return ClassName( name: json['name'] as String, - ); + ); } ``` diff --git a/versioned_docs/version-2.9.0/06-concepts/08-caching.md b/versioned_docs/version-2.9.0/06-concepts/08-caching.md index 2fe38e6d..4bd584a4 100644 --- a/versioned_docs/version-2.9.0/06-concepts/08-caching.md +++ b/versioned_docs/version-2.9.0/06-concepts/08-caching.md @@ -48,7 +48,7 @@ Future 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; diff --git a/versioned_docs/version-3.0.0/06-concepts/03-serialization.md b/versioned_docs/version-3.0.0/06-concepts/03-serialization.md index 438af210..25abdc3f 100644 --- a/versioned_docs/version-3.0.0/06-concepts/03-serialization.md +++ b/versioned_docs/version-3.0.0/06-concepts/03-serialization.md @@ -6,9 +6,9 @@ For most purposes, you will want to use Serverpod's native serialization. Howeve ```dart Map toJson() { - return { - name: 'John Doe', - }; + return { + 'name': 'John Doe', + }; } ``` @@ -16,11 +16,11 @@ For most purposes, you will want to use Serverpod's native serialization. Howeve ```dart factory ClassName.fromJson( - Map json, + Map json, ) { - return ClassName( + return ClassName( name: json['name'] as String, - ); + ); } ``` diff --git a/versioned_docs/version-3.0.0/06-concepts/08-caching.md b/versioned_docs/version-3.0.0/06-concepts/08-caching.md index 2fe38e6d..4bd584a4 100644 --- a/versioned_docs/version-3.0.0/06-concepts/08-caching.md +++ b/versioned_docs/version-3.0.0/06-concepts/08-caching.md @@ -48,7 +48,7 @@ Future 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; diff --git a/versioned_docs/version-3.1.0/06-concepts/03-serialization.md b/versioned_docs/version-3.1.0/06-concepts/03-serialization.md index 438af210..25abdc3f 100644 --- a/versioned_docs/version-3.1.0/06-concepts/03-serialization.md +++ b/versioned_docs/version-3.1.0/06-concepts/03-serialization.md @@ -6,9 +6,9 @@ For most purposes, you will want to use Serverpod's native serialization. Howeve ```dart Map toJson() { - return { - name: 'John Doe', - }; + return { + 'name': 'John Doe', + }; } ``` @@ -16,11 +16,11 @@ For most purposes, you will want to use Serverpod's native serialization. Howeve ```dart factory ClassName.fromJson( - Map json, + Map json, ) { - return ClassName( + return ClassName( name: json['name'] as String, - ); + ); } ``` diff --git a/versioned_docs/version-3.1.0/06-concepts/08-caching.md b/versioned_docs/version-3.1.0/06-concepts/08-caching.md index 2fe38e6d..4bd584a4 100644 --- a/versioned_docs/version-3.1.0/06-concepts/08-caching.md +++ b/versioned_docs/version-3.1.0/06-concepts/08-caching.md @@ -48,7 +48,7 @@ Future 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; diff --git a/versioned_docs/version-3.2.0/06-concepts/03-serialization.md b/versioned_docs/version-3.2.0/06-concepts/03-serialization.md index 438af210..25abdc3f 100644 --- a/versioned_docs/version-3.2.0/06-concepts/03-serialization.md +++ b/versioned_docs/version-3.2.0/06-concepts/03-serialization.md @@ -6,9 +6,9 @@ For most purposes, you will want to use Serverpod's native serialization. Howeve ```dart Map toJson() { - return { - name: 'John Doe', - }; + return { + 'name': 'John Doe', + }; } ``` @@ -16,11 +16,11 @@ For most purposes, you will want to use Serverpod's native serialization. Howeve ```dart factory ClassName.fromJson( - Map json, + Map json, ) { - return ClassName( + return ClassName( name: json['name'] as String, - ); + ); } ``` diff --git a/versioned_docs/version-3.2.0/06-concepts/08-caching.md b/versioned_docs/version-3.2.0/06-concepts/08-caching.md index 2fe38e6d..4bd584a4 100644 --- a/versioned_docs/version-3.2.0/06-concepts/08-caching.md +++ b/versioned_docs/version-3.2.0/06-concepts/08-caching.md @@ -48,7 +48,7 @@ Future 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; diff --git a/versioned_docs/version-3.3.0/06-concepts/03-serialization.md b/versioned_docs/version-3.3.0/06-concepts/03-serialization.md index 438af210..25abdc3f 100644 --- a/versioned_docs/version-3.3.0/06-concepts/03-serialization.md +++ b/versioned_docs/version-3.3.0/06-concepts/03-serialization.md @@ -6,9 +6,9 @@ For most purposes, you will want to use Serverpod's native serialization. Howeve ```dart Map toJson() { - return { - name: 'John Doe', - }; + return { + 'name': 'John Doe', + }; } ``` @@ -16,11 +16,11 @@ For most purposes, you will want to use Serverpod's native serialization. Howeve ```dart factory ClassName.fromJson( - Map json, + Map json, ) { - return ClassName( + return ClassName( name: json['name'] as String, - ); + ); } ``` diff --git a/versioned_docs/version-3.3.0/06-concepts/08-caching.md b/versioned_docs/version-3.3.0/06-concepts/08-caching.md index 2fe38e6d..4bd584a4 100644 --- a/versioned_docs/version-3.3.0/06-concepts/08-caching.md +++ b/versioned_docs/version-3.3.0/06-concepts/08-caching.md @@ -48,7 +48,7 @@ Future 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; diff --git a/versioned_docs/version-3.4.0/06-concepts/03-serialization.md b/versioned_docs/version-3.4.0/06-concepts/03-serialization.md index 438af210..25abdc3f 100644 --- a/versioned_docs/version-3.4.0/06-concepts/03-serialization.md +++ b/versioned_docs/version-3.4.0/06-concepts/03-serialization.md @@ -6,9 +6,9 @@ For most purposes, you will want to use Serverpod's native serialization. Howeve ```dart Map toJson() { - return { - name: 'John Doe', - }; + return { + 'name': 'John Doe', + }; } ``` @@ -16,11 +16,11 @@ For most purposes, you will want to use Serverpod's native serialization. Howeve ```dart factory ClassName.fromJson( - Map json, + Map json, ) { - return ClassName( + return ClassName( name: json['name'] as String, - ); + ); } ``` diff --git a/versioned_docs/version-3.4.0/06-concepts/08-caching.md b/versioned_docs/version-3.4.0/06-concepts/08-caching.md index 89c3ffff..37be9a81 100644 --- a/versioned_docs/version-3.4.0/06-concepts/08-caching.md +++ b/versioned_docs/version-3.4.0/06-concepts/08-caching.md @@ -87,7 +87,7 @@ Future 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;