Skip to content

Commit 895d560

Browse files
fix: Object layer parsing for JSON format
- When loading in JSON from object layers didn't get parsed and where empty - Default values added for ellipse and point properties (as they might not be present in JSON)
1 parent 788789a commit 895d560

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

packages/tiled/lib/src/layer.dart

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,12 @@ abstract class Layer {
194194
parser.getString('color', defaults: ObjectGroup.defaultColorHex);
195195
final color =
196196
parser.getColor('color', defaults: ObjectGroup.defaultColor);
197-
final objects = parser.getChildrenAs('object', TiledObject.parse);
197+
198+
final objects = parser.formatSpecificParsing(
199+
(json) => json.getChildrenAs('objects', TiledObject.parse),
200+
(xml) => xml.getChildrenAs('object', TiledObject.parse),
201+
);
202+
198203
layer = ObjectGroup(
199204
id: id,
200205
name: name,

packages/tiled/lib/src/objects/tiled_object.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,11 @@ class TiledObject {
118118
);
119119

120120
final ellipse = parser.formatSpecificParsing(
121-
(json) => json.getBool('ellipse'),
121+
(json) => json.getBool('ellipse', defaults: false),
122122
(xml) => xml.getChildren('ellipse').isNotEmpty,
123123
);
124124
final point = parser.formatSpecificParsing(
125-
(json) => json.getBool('point'),
125+
(json) => json.getBool('point', defaults: false),
126126
(xml) => xml.getChildren('point').isNotEmpty,
127127
);
128128
final text = parser.getSingleChildOrNullAs('text', Text.parse);

0 commit comments

Comments
 (0)