Skip to content

Commit

Permalink
added results.json docs
Browse files Browse the repository at this point in the history
  • Loading branch information
mattiasnordqvist committed Sep 25, 2024
1 parent bbd3ae8 commit ce84ebb
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions Results/DotNetThoughts.Results.Json/ReadMe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Results.Json

Package contains code to help serialize and deserialize Result objects to and from JSON.
`JsonConverterFactoryForResultOfT` is a `JsonConverterFactory` that can create `JsonConverter` objects for any `Result<T>` object.
Remember, a Result representing one or more Errors contains a list of objects implementing the `IError` interface.
The actual type of an Error object is not included when serialized. This means, that when deserializing that Error again, it can't be deserialized to its original type.
Instead, the Error object is deserialized to a generic `DeserializedError` object.

A serialized _Successful_ `Result<T>` will look like this:
```json
{
"Success": true,
"Value": "Some value"
}
```
A serialized _Successful_ `Result<Unit>` will look like this:
```json
{
"Success": true
}
```
A serialized _Error_ `Result<T>` or `Result<Unit>` will look like this:
```json
{
"Success": false,
"Errors": [
{
"Type": "MyError",
"Message": "Some error message"
"Data": {
"Key": "value",
}
}
]
}
```

0 comments on commit ce84ebb

Please sign in to comment.