-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #178 from eclipse-thingweb/serialization
feat!: implement proper serialization logic
- Loading branch information
Showing
31 changed files
with
1,065 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Copyright 2024 Contributors to the Eclipse Foundation. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
// | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
|
||
import "../form.dart"; | ||
import "../link.dart"; | ||
import "serializable.dart"; | ||
|
||
/// Extension that provides JSON serialization for [List]s of [Link]s. | ||
extension SerializableList on List<Serializable> { | ||
/// Converts this [List] of [Serializable] elements to JSON. | ||
List<dynamic> toJson() => | ||
map((listItem) => listItem.toJson()).toList(growable: false); | ||
} | ||
|
||
/// Extension that provides JSON serialization for [List]s of [Form]s. | ||
extension SerializableMap on Map<String, Serializable> { | ||
/// Converts this [Map] of [Serializable] key-value pairs to JSON. | ||
Map<String, dynamic> toJson() => | ||
map((key, value) => MapEntry(key, value.toJson())); | ||
} | ||
|
||
/// Extension that provides JSON serialization for [List]s of [Uri]s. | ||
extension UriListToJsonExtension on List<Uri> { | ||
/// Converts this [List] of [Uri]s to JSON. | ||
List<String> toJson() => map((uri) => uri.toString()).toList(growable: false); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// Copyright 2024 Contributors to the Eclipse Foundation. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
// | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
|
||
/// Interface for converting a class object [toJson]. | ||
abstract interface class Serializable { | ||
/// Converts this class object into a JSON value. | ||
dynamic toJson(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.