Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MapJsonObject: the JsonObjectSerializer serializer is not recognized #1161

Open
danielgomezrico opened this issue Jun 9, 2022 · 2 comments
Assignees

Comments

@danielgomezrico
Copy link
Contributor

danielgomezrico commented Jun 9, 2022

  1. If I declare a field like: MapJsonObject it breaks saying:
MapJsonObject get payload;

Error:

type 'ListJsonObject' is not a subtype of type 'MapJsonObject' in type cast

image

Even If I declare the JsonObjectSerializer (like #1159) like this:

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

final Serializers serializers = (_$serializers.toBuilder()
      ..add(JsonObjectSerializer())
  1. If I declare the field like JsonObject it does not break, and internally it contains the proper MapJsonObject. It seems that the way to find the proper serializer uses

Expected

If I declare the Type like MapJsonObject it should work fine so everyone that use the model could know if it contains a list, a map or what.

Investigation

@davidmorgan
Copy link
Collaborator

Thanks for the issue report.

It never occurred to me that someone would want to do this :) but I agree it makes sense. I'll mark it as a feature request and see if there's some way to support it--next time I am working on built_value features. (I only do that every quarter or so).

@danielgomezrico
Copy link
Contributor Author

It is one solution in order to be able to serialize/deserialize Map<String, dynamic> attributes, I haven't found another way

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants