decode method
Decode any type value
Implementation
dynamic decode(dynamic value) {
if (value is List) {
return _convertJSONArrayToList(value);
}
if (value is bool) {
return value;
}
if (value is int) {
return value.toInt();
}
if (value is double) {
return value.toDouble();
}
if (value is num) {
return value;
}
if (!(value is Map)) {
return value;
}
Map map = value;
if (!map.containsKey("__type")) {
return _convertJSONObjectToMap(map);
}
switch (map["__type"]) {
case "Date":
String iso = map["iso"];
return parseDateFormat.parse(iso);
case "Bytes":
String val = map["base64"];
return base64.decode(val);
case "Pointer":
String objectId = map["objectId"];
String className = map["className"];
return new ParseObject(className, objectId: objectId);
case "Object":
String objectId = map["objectId"];
String className = map["className"];
return new ParseObject(className, objectId: objectId, json: map);
case "File":
return new ParseFile(map);
case "GeoPoint":
num latitude = map["latitude"] ?? 0.0;
num longitude = map["longitude"] ?? 0.0;
return new ParseGeoPoint.set(latitude.toDouble(), longitude.toDouble());
}
return null;
}