Various improvements to serialization of data encoded via Base64 to Json
This commit is contained in:
@@ -306,13 +306,8 @@ void JsonWriter::CommonValue(const ::CommonValue& value)
|
||||
Matrix(value.AsMatrix);
|
||||
break;
|
||||
case CommonType::Blob:
|
||||
{
|
||||
::Array<char> base64;
|
||||
base64.Resize(Encryption::Base64EncodeLength(value.AsBlob.Length));
|
||||
Encryption::Base64Encode(value.AsBlob.Data, value.AsBlob.Length, base64.Get());
|
||||
String(base64.Get(), base64.Count());
|
||||
Blob(value.AsBlob.Data, value.AsBlob.Length);
|
||||
break;
|
||||
}
|
||||
case CommonType::Object:
|
||||
Guid(value.GetObjectId());
|
||||
break;
|
||||
|
||||
@@ -588,16 +588,6 @@ namespace Serialization
|
||||
}
|
||||
template<typename T, typename AllocationType = HeapAllocation>
|
||||
inline void Deserialize(ISerializable::DeserializeStream& stream, Array<T, AllocationType>& v, ISerializeModifier* modifier)
|
||||
{
|
||||
if (!stream.IsArray())
|
||||
return;
|
||||
const auto& streamArray = stream.GetArray();
|
||||
v.Resize(streamArray.Size());
|
||||
for (int32 i = 0; i < v.Count(); i++)
|
||||
Deserialize(streamArray[i], (T&)v[i], modifier);
|
||||
}
|
||||
template<typename AllocationType = HeapAllocation>
|
||||
inline void Deserialize(ISerializable::DeserializeStream& stream, Array<byte, AllocationType>& v, ISerializeModifier* modifier)
|
||||
{
|
||||
if (stream.IsArray())
|
||||
{
|
||||
@@ -606,12 +596,12 @@ namespace Serialization
|
||||
for (int32 i = 0; i < v.Count(); i++)
|
||||
Deserialize(streamArray[i], v[i], modifier);
|
||||
}
|
||||
else if (stream.IsString())
|
||||
else if (TIsPODType<T>::Value && stream.IsString())
|
||||
{
|
||||
// byte[] encoded as Base64
|
||||
// T[] encoded as Base64
|
||||
const StringAnsiView streamView(stream.GetStringAnsiView());
|
||||
v.Resize(Encryption::Base64DecodeLength(*streamView, streamView.Length()));
|
||||
Encryption::Base64Decode(*streamView, streamView.Length(), v.Get());
|
||||
v.Resize(Encryption::Base64DecodeLength(*streamView, streamView.Length()) / sizeof(T));
|
||||
Encryption::Base64Decode(*streamView, streamView.Length(), (byte*)v.Get());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user