Seems a bit of interest int he past, but anyone know of any update Json Serializers / Deserializers to work with TinyCLR?
Guess I can do it in other ways, but just starting to think about it.
Basically I have a device constantly transmitting data from a I2C device and sending that out over a UART port.
I want it to send Data and also receive Commands (eg, simple example Stop/Start/Set Params etc)
Serializing is simple enough, as can be hard coded as its just going to be something like
return ($“{{ "Data": {{ "Dir":"{Heading}", "Cal": "{true}" }} }}”);
{ “Data”: { “Dir”: “360”, “Cal”: “true” }}
or
{ “CmdACK”: { “GainSet”: “100” }}
That output will be consumed by a Application written in full dot net, so can use JSon library there to DeSerialize easy enough if needed.
But for the TinyCLR app on the device to DeSerialize I wanted to use Reflection to actually create a class object of a certain received type, which might vary. eg Command Object, other Objects of different type. But that’s not available.
eg
{ “Command”: { “Cmd”: “SetParams”, “Parms”: [ {“Gain”: “100”}, {“Time”: “100”}] }}
pseudo:
Class Command {
public string Cmd;
public string Params;
}
I might be able to get away with just using a generic object like above “Command” to send anything I need to the device to control it, and ‘tokenize’ it on the device as a generic Command object, but just wondering if anyone had any good suggestions?
Ta