Adobe spits out 2 possible JSON formats for a file I’m using, one uses full names but the other uses abbreviations. but I can use some fuckery to rename the fields to something more readable.
private typedef RawAnimFileDataShort =
{
AN:RawAnimationDataShort,
MD:RawMetaDataShort,
SD:Null<RawSymbolDictionaryDataShort>
}
abstract AnimFileDataShort(RawAnimFileDataShort) from RawAnimFileDataShort
{
public var animation(get, never):AnimationDataShort;
public var symbols(get, never):Null<SymbolDictionaryDataShort>;
public var metadata(get, never):MetadataShort;
inline function get_animation() return this.AN;
inline function get_symbols() return this.SD;
inline function get_metadata() return this.MD;
}
private typedef RawAnimFileDataLong =
{
ANIMATION:RawAnimationDataLong,
metadata:RawMetaDataLong,
SYMBOL_DICTIONARY:Null<RawSymbolDictionaryDataLong>
}
abstract AnimFileDataLong(RawAnimFileDataLong) from RawAnimFileDataLong
{
public var animation(get, never):AnimationDataLong;
public var symbols(get, never):Null<SymbolDictionaryDataLong>;
public var metadata(get, never):MetadataLong;
inline function get_animation() return this.ANIMATION;
inline function get_symbols() return this.SYMBOL_DICTIONARY;
inline function get_metadata() return this.metadata;
}
Is there some way to unify these types so I can traverse either format without needing to know which format i’m actually dealing with, assuming the abstracts all have the same fields?