Convert representation of value
based on type
and currentValue
.
Object deserializeValue(String value, Object currentValue, Type type) {
var handler = _typeHandlers[type];
if (handler != null) return handler(value, currentValue);
try {
// If the string is an object, we can parse is with the JSON library.
// include convenience replace for single-quotes. If the author omits
// quotes altogether, parse will fail.
return JSON.decode(value.replaceAll("'", '"'));
// TODO(jmesserly): deserialized JSON is not assignable to most objects in
// Dart. We should attempt to convert it appropriately.
} catch (e) {
// The object isn't valid JSON, return the raw value
return value;
}
}