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

YouTubeApi's VideoListResponse.toJson does not correctly serialize items #438

Open
atn832 opened this issue Sep 4, 2022 · 2 comments
Open

Comments

@atn832
Copy link

atn832 commented Sep 4, 2022

In googleapis 0.9.1, serialization to Json does not correctly convert items to Json. Is this intentional? The same goes for Channel's contentDetails.

  VideoListResponse.fromJson(core.Map _json)
      : this(
          etag: _json.containsKey('etag') ? _json['etag'] as core.String : null,
          eventId: _json.containsKey('eventId')
              ? _json['eventId'] as core.String
              : null,
          items: _json.containsKey('items')
              ? (_json['items'] as core.List)
                  .map((value) => Video.fromJson(
                      value as core.Map<core.String, core.dynamic>))
                  .toList()
              : null,
          ...
        );

  core.Map<core.String, core.dynamic> toJson() => {
        if (etag != null) 'etag': etag!,
        if (eventId != null) 'eventId': eventId!,
        // This should probably be something like `items.map((item) => item.toJson())`
        if (items != null) 'items': items!,
        ...
      };
}
@kevmoo
Copy link
Collaborator

kevmoo commented Sep 8, 2022

This is by design, but the design should probably be changed.

Work-around: jsonDecode(jsonEncode(object))

@atn832
Copy link
Author

atn832 commented Sep 9, 2022

Thanks for the workaround!

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

No branches or pull requests

2 participants