extractPropertyType function

PropertiesTypes extractPropertyType(
  1. Map<String, dynamic> json
)

Extract the property type of a json property.

This because sometimes the json response doesn't contain a type field but the type can be deduced by the field with the content.

Implementation

PropertiesTypes extractPropertyType(Map<String, dynamic> json) {
  if (json.keys.contains('type')) {
    return stringToPropertyType(json['type']);
  } else {
    PropertiesTypes type = PropertiesTypes.None;
    json.keys.forEach((key) {
      if (all_str_property_types.contains(key)) {
        type = stringToPropertyType(key);
      }
    });
    return type;
  }
}