Allow nullable fields to be null
parent
bc634ba326
commit
5ba780acf9
|
@ -259,7 +259,7 @@ pub const LayerInstance = struct {
|
||||||
.__pxTotalOffsetX = integer(layer_obj.get("__pxTotalOffsetX")) orelse return error.InvalidTotalOffsetX,
|
.__pxTotalOffsetX = integer(layer_obj.get("__pxTotalOffsetX")) orelse return error.InvalidTotalOffsetX,
|
||||||
.__pxTotalOffsetY = integer(layer_obj.get("__pxTotalOffsetY")) orelse return error.InvalidTotalOffsetY,
|
.__pxTotalOffsetY = integer(layer_obj.get("__pxTotalOffsetY")) orelse return error.InvalidTotalOffsetY,
|
||||||
.__tilesetDefUid = integer(layer_obj.get("__tilesetDefUid")),
|
.__tilesetDefUid = integer(layer_obj.get("__tilesetDefUid")),
|
||||||
.__tilesetRelPath = string(layer_obj.get("__tilesetRelPath")) orelse return error.InvalidTilesetRelPath,
|
.__tilesetRelPath = string(layer_obj.get("__tilesetRelPath")),
|
||||||
.__type = __type,
|
.__type = __type,
|
||||||
.autoLayerTiles = try TileInstance.fromJSONMany(alloc, layer_obj.get("autoLayerTiles")),
|
.autoLayerTiles = try TileInstance.fromJSONMany(alloc, layer_obj.get("autoLayerTiles")),
|
||||||
.entityInstances = try EntityInstance.fromJSONMany(alloc, layer_obj.get("entityInstances")),
|
.entityInstances = try EntityInstance.fromJSONMany(alloc, layer_obj.get("entityInstances")),
|
||||||
|
@ -369,7 +369,7 @@ const EntityInstance = struct {
|
||||||
const __pivot = posf_from_value(entity.get("__pivot")) orelse return error.InvalidPivot;
|
const __pivot = posf_from_value(entity.get("__pivot")) orelse return error.InvalidPivot;
|
||||||
const __smartColor = string(entity.get("__smartColor")) orelse return error.InvalidSmartColor;
|
const __smartColor = string(entity.get("__smartColor")) orelse return error.InvalidSmartColor;
|
||||||
const __tags = try string_list(alloc, entity.get("__tags"));
|
const __tags = try string_list(alloc, entity.get("__tags"));
|
||||||
const __tile = try TilesetRectangle.fromJSON(entity.get("__tile"));
|
const __tile = if (entity.get("__tile")) |__tile| try TilesetRectangle.fromJSON(__tile) else null;
|
||||||
const defUid = integer(entity.get("defUid")) orelse return error.InvalidDefUid;
|
const defUid = integer(entity.get("defUid")) orelse return error.InvalidDefUid;
|
||||||
const fieldInstances = try FieldInstance.fromJSONMany(alloc, entity.get("fieldInstances"));
|
const fieldInstances = try FieldInstance.fromJSONMany(alloc, entity.get("fieldInstances"));
|
||||||
const height = integer(entity.get("height")) orelse return error.InvalidHeight;
|
const height = integer(entity.get("height")) orelse return error.InvalidHeight;
|
||||||
|
@ -422,7 +422,7 @@ pub const FieldInstance = struct {
|
||||||
pub fn fromJSON(field_value: ?std.json.Value) !?FieldInstance {
|
pub fn fromJSON(field_value: ?std.json.Value) !?FieldInstance {
|
||||||
const field = object(field_value) orelse return error.InvalidFieldInstance;
|
const field = object(field_value) orelse return error.InvalidFieldInstance;
|
||||||
const __identifier = string(field.get("__identifier")) orelse return error.InvalidIdentifier;
|
const __identifier = string(field.get("__identifier")) orelse return error.InvalidIdentifier;
|
||||||
const __tile = try TilesetRectangle.fromJSON(field.get("__tile"));
|
const __tile = if (field.get("__tile")) |__tile| try TilesetRectangle.fromJSON(__tile) else null;
|
||||||
const __type = string(field.get("__type")) orelse return error.InvalidType;
|
const __type = string(field.get("__type")) orelse return error.InvalidType;
|
||||||
const __value = string(field.get("__value")) orelse return error.InvalidValue;
|
const __value = string(field.get("__value")) orelse return error.InvalidValue;
|
||||||
const defUid = integer(field.get("defUid")) orelse return error.InvalidIDefUid;
|
const defUid = integer(field.get("defUid")) orelse return error.InvalidIDefUid;
|
||||||
|
|
Loading…
Reference in New Issue