Main Site Documentation

How to serialize any object?


#1

Hi
Can i serialize any poco object to type of xml, json or another. Is Reflection.Serialize() not imposible?

Thanks


#2

I don’t think this is implemented in NETMF.

Goto http://code.tinyclr.com and search for json


#3

Hımm, it’s great. Do you have json parser?


#4

Always worth checking the WiKi.

http://wiki.tinyclr.com/index.php?title=Serialization


#5

If you are using one of GHI’s “smallest” offerings (e.g. Panda), serialization doesn’t work. You have to roll your own code.

Per: http://wiki.tinyclr.com/index.php?title=Serialization

For serialization on the Panda II (to send POCOs across a serial connection in my case) I’ve rolled my own. Basically, I have a Serialize() and Deserialize() method on an object where I turn it into a byte[] or rehydrate an object from a byte[].

See:



Microsoft.SPOT.Hardware.Utility.ExtractRangeFromArray()
Microsoft.SPOT.Hardware.Utility.ExtractValueFromArray()
Microsoft.SPOT.Hardware.Utility.InsertValueIntoArray()

//convert a byte array to a string
char[] CharArray = System.Text.UTF8Encoding.UTF8.GetChars(somebyteArray);
string someString = new string(nameCharArray);

//convert a string to a byte array
byte[] someBytes = System.Text.Encoding.UTF8.GetBytes("Good Luck");