-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- adds doc comments and json shorthands
- Loading branch information
Showing
2 changed files
with
29 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package serialization | ||
|
||
var jsonContentType = "application/json" | ||
|
||
// SerializeToJson serializes the given model to JSON | ||
func SerializeToJson(model Parsable) ([]byte, error) { | ||
return Serialize(jsonContentType, model) | ||
} | ||
|
||
// SerializeCollectionToJson serializes the given models to JSON | ||
func SerializeCollectionToJson(models []Parsable) ([]byte, error) { | ||
return SerializeCollection(jsonContentType, models) | ||
} | ||
|
||
// DeserializeFromJson deserializes the given JSON to a model | ||
func DeserializeFromJson(content []byte, parsableFactory ParsableFactory) (Parsable, error) { | ||
return Deserialize(jsonContentType, content, parsableFactory) | ||
} | ||
|
||
// DeserializeCollectionFromJson deserializes the given JSON to a collection of models | ||
func DeserializeCollectionFromJson(content []byte, parsableFactory ParsableFactory) ([]Parsable, error) { | ||
return DeserializeCollection(jsonContentType, content, parsableFactory) | ||
} |
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