> For the complete documentation index, see [llms.txt](https://darwin-framework.gitbook.io/dogs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://darwin-framework.gitbook.io/dogs/guides/3.-lets-serialize.md).

# 3. Let's Serialize

You can encode and decode objects using the global dogs variable. All default serializer expand the dogs engine instance with \<format>Encode and \<format>Decode methods taking a required generic type argument and a value to encode or decode. This could look something like this:

```dart
  var encoded = dogs.jsonEncode<Person>(person); // Returns a string
  var decoded = dogs.jsonDecode<Person>(encoded); // Returns a 'Person'
```

You can also encode and decode list, sets, and other iterables using the respective methods:

```dart
  var encoded = dogs.jsonEncodeList<Person>([personA,personB]);
  var decoded = dogs.jsonDecodeList<Person>(encoded);
```

{% hint style="warning" %}
Don't forget to **explicitly specify the type** of the encoded value using the **generic type** **argument** of the convert method. Type Inference can work in some cases, but when it doesn't, it leads to hard-to-diagnose bugs as the code is technically valid. &#x20;
{% endhint %}
