You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
projectitis
changed the title
bug: AssetCache.readJson fails for json files where the root object is an array
bug: AssetCache.readJson fails for json files where the root is an array
Aug 26, 2023
Current bug behavior
Reading a JSON file using
AssetCache.readJson
results in an error if the JSON file root element is an array.An example JSON file that meets this criteria is
The error is
This is because it attempts to cast the result to a
Map<String, dynamic>
, however, a JSON file can also be aList<dynamic>
.Expected behavior
AssetCache.readJson
should return aFuture<dynamic>
(It usesjsonDecode
under the hood, which returnsdynamic
).Steps to reproduce
import 'package:flame/cache.dart';
AssetsCache().readJson('test.json')
More environment information
More information
I can provide the fix. It's very simple and I think it will be backwards compatible in most cases?
The text was updated successfully, but these errors were encountered: