as<E> method
Allow transformation back to popular data types For using the as() and asXX() methods, We're assuming it is safe to transform to utf8 Strings.
This method provides a common generic way of transforming the bytes
to one the supported serialization formats. As an example:
as
Implementation
E as<E>(){
assert(_isStream != null && !_isStream);
if( E == String )
return asString() as E;
else if( E.toString().startsWith("Map<") )
return asMap() as E;
else if( E.toString().startsWith("List<") )
return asList() as E;
else if( E == int )
return asInt() as E;
else if( E == double )
return asDouble() as E;
else if( E == num )
return asNumber() as E;
else if( E == bool )
return asBool() as E;
throw "Unsupported return type. Deserialize to one of the supported formats";
}