From 3ef497f3e1f6d31b23fc9bcef77c66f975e242b5 Mon Sep 17 00:00:00 2001 From: Jason Elie Bou Kheir <5115126+jasonboukheir@users.noreply.github.com> Date: Sun, 10 Oct 2021 14:29:13 -0700 Subject: [PATCH] feat(serialization): :sparkles: add support for deserializing `byte[]` --- .../CareBoo.AlgoSdk/AlgoApi/AlgoApiSerializer.cs | 6 ++++++ .../Json/JsonReader/JsonReader.Object.cs.meta | 11 +++++++++++ 2 files changed, 17 insertions(+) create mode 100644 Packages/com.careboo.unity-algorand-sdk/CareBoo.AlgoSdk/Serialization/Json/JsonReader/JsonReader.Object.cs.meta diff --git a/Packages/com.careboo.unity-algorand-sdk/CareBoo.AlgoSdk/AlgoApi/AlgoApiSerializer.cs b/Packages/com.careboo.unity-algorand-sdk/CareBoo.AlgoSdk/AlgoApi/AlgoApiSerializer.cs index 87d9336c2..5b9d599aa 100644 --- a/Packages/com.careboo.unity-algorand-sdk/CareBoo.AlgoSdk/AlgoApi/AlgoApiSerializer.cs +++ b/Packages/com.careboo.unity-algorand-sdk/CareBoo.AlgoSdk/AlgoApi/AlgoApiSerializer.cs @@ -8,6 +8,12 @@ namespace AlgoSdk { public static class AlgoApiSerializer { + public static T Deserialize(byte[] bytes, ContentType contentType) + { + using var nativeBytes = new NativeArray(bytes, Allocator.Temp); + return Deserialize(nativeBytes.AsReadOnly(), contentType); + } + public static T Deserialize(NativeArray.ReadOnly bytes, ContentType contentType) { return contentType switch diff --git a/Packages/com.careboo.unity-algorand-sdk/CareBoo.AlgoSdk/Serialization/Json/JsonReader/JsonReader.Object.cs.meta b/Packages/com.careboo.unity-algorand-sdk/CareBoo.AlgoSdk/Serialization/Json/JsonReader/JsonReader.Object.cs.meta new file mode 100644 index 000000000..95d9ce2a6 --- /dev/null +++ b/Packages/com.careboo.unity-algorand-sdk/CareBoo.AlgoSdk/Serialization/Json/JsonReader/JsonReader.Object.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: c9d67610463212e41a99b2ab4c3b932b +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: