google / google/built_value.dart

Map `Map<String, dynamic>` with JsonObject: the JsonObjectSerializer serializer is not included automatically

Open
#1,159 4 comments 1 reaction 1 assignee Claimed by @davidmorgan View on GitHub
question
Dominant language
Dart
Stars
886
Forks
195
Avg merge
1d 11h
Merged PRs (30d)
4

Description

Hi

I need to have a field that is a `Map` because theres another field that says me what kind of type it is and so we need to get it to parse it latter on.

If I declare a field like `MapJsonObject` or `JsonObject` I get the error "no serializer for JsonObject

After some research theres a `JsonObjectSerializer` and if I import it and add it manually like this it works:

```dart
import 'package:built_value/src/json_object_serializer.dart';

final Serializers serializers = (_$serializers.toBuilder()
..add(JsonObjectSerializer())
```

# Why it is important?

Because if you want to map a `Map` field this looks like the only way to go. I see this issues related to this one:
- https://github.com/google/built_value.dart/issues/405
- https://github.com/google/built_value.dart/issues/759
- https://github.com/google/built_value.dart/issues/887

# Ideas
1. The serializer should include this serializer internally and I wouldnt need to add the serializer manually neither add the import
2. Make that serializer public for the library so I dont get this warning and I can add it manually:
![image](https://user-images.githubusercontent.com/76348/172953338-a28a9453-c6ad-4a3a-b932-f6c7d0ca0350.png)
3. It looks like this is an issue for everyone and it may be important to add this as a section in the docs or on some FAQ, WDYT?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.