Class Encoder
Convenience class for serializing and deserializing arbitrary objects to json or msgpack.
Inheritance
Inherited Members
Namespace: Algorand.Utils
Assembly: Algorand.dll
Syntax
public static class Encoder
Methods
| Improve this Doc View SourceDecodeFromJson<T>(string)
Decode a json string to an object.
Declaration
public static T DecodeFromJson<T>(string json)
Parameters
Type | Name | Description |
---|---|---|
string | json | json string |
Returns
Type | Description |
---|---|
T | object |
Type Parameters
Name | Description |
---|---|
T | object type |
DecodeFromMsgPack<T>(byte[])
Convenience method for deserializing arbitrary objects encoded with canonical msg-pack
Declaration
public static T DecodeFromMsgPack<T>(byte[] input)
Parameters
Type | Name | Description |
---|---|---|
byte[] | input | input byte array representing canonical msg-pack encoding |
Returns
Type | Description |
---|---|
T | deserialized object |
Type Parameters
Name | Description |
---|---|
T | object type |
EncodeToHexStr(byte[])
Convenience method for writing bytes as hex.
Declaration
public static string EncodeToHexStr(byte[] bytes)
Parameters
Type | Name | Description |
---|---|---|
byte[] | bytes | bytes input to encodeToMsgPack as hex string |
Returns
Type | Description |
---|---|
string | encoded hex string |
EncodeToJson(object)
Encode an object as json.
Declaration
public static string EncodeToJson(object o)
Parameters
Type | Name | Description |
---|---|---|
object | o | object to encode |
Returns
Type | Description |
---|---|
string | json string |
EncodeToMsgPackNoOrder(object)
Declaration
public static byte[] EncodeToMsgPackNoOrder(object o)
Parameters
Type | Name | Description |
---|---|---|
object | o |
Returns
Type | Description |
---|---|
byte[] |
EncodeToMsgPackOrdered(List<SignedTransaction>)
Convenience method for serializing lists without the list wrapper: just concat each serialised object
Declaration
public static byte[] EncodeToMsgPackOrdered(List<SignedTransaction> o)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.List<T><SignedTransaction> | o | the object to serializing |
Returns
Type | Description |
---|---|
byte[] | serialized object |
EncodeToMsgPackOrdered(object)
Convenience method for serializing arbitrary objects.
Declaration
public static byte[] EncodeToMsgPackOrdered(object o)
Parameters
Type | Name | Description |
---|---|---|
object | o | the object to serializing |
Returns
Type | Description |
---|---|
byte[] | serialized object |
HexStringToByteArray(string)
Declaration
public static byte[] HexStringToByteArray(string hex)
Parameters
Type | Name | Description |
---|---|---|
string | hex |
Returns
Type | Description |
---|---|
byte[] |
ToBigEndianBytes(ulong)
Convenience method to get a value as a big-endian byte array
Declaration
public static byte[] ToBigEndianBytes(this ulong val)
Parameters
Type | Name | Description |
---|---|---|
ulong | val |
Returns
Type | Description |
---|---|
byte[] |