This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Converts an enumeration value to its string representation without the type name | |
enumStr(dynamic enumValue) { | |
return enumValue?.toString()?.split('.')?.last; | |
} | |
// Converts a string to an enum value. Works as the inverse of [enumStr()]. | |
parseEnum(List<dynamic> values, String value) { | |
return value == null ? null : values.firstWhere((v) => enumStr(v) == value); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def flatten_json(json): | |
if type(json) == dict: | |
for k, v in list(json.items()): | |
if type(v) == dict: | |
flatten_json(v) | |
json.pop(k) | |
for k2, v2 in v.items(): | |
json[k+"."+k2] = v2 | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CoreTeam: &CoreTeam | |
Characters: | |
- Mario | |
- Luigi | |
ExtendedTeam: &ExtendedTeam | |
<<: *CoreTeam | |
Characters+: | |
- Princess Peach | |
- Yoshi |