azure iot hub - UpdateReportedPropertiesAsync with complex types? -


i'm trying update azure iot device twin properties this:

static async void mainasync() {     deviceclient deviceclient = deviceclient.createfromconnectionstring(connectionstring);      twincollection reportedproperties = new twincollection();       dynamic heatingmodes = new[]     {         new { id="out2", name="comfort" },         new { id="out", name="away" },     };      reportedproperties["heatingmode"] = "away";     reportedproperties["supportedheatingmodes"] = heatingmodes;      await deviceclient.updatereportedpropertiesasync(reportedproperties); } 

the above code not work , none of device twin properties not updated.

if comment out line works fine , heatingmode property updated expected:

reportedproperties["supportedheatingmodes"] = heatingmodes; 

i have tried use regular (not dynamic) type heatingmodes, not work either.

i tried manually serialize object json:

reportedproperties["supportedheatingmodes"] = jsonconvert.serializeobject(heatingmodes); 

but, resulting json kind of ugly escaped quotes:

device twin properties

why doesn't updating supportedheatingmodes property work objects based on complex types?

any other workarounds?

have @ msdn document understand , use device twins in iot hub , described:

all values in json objects can of following json types: boolean, number, string, object. arrays not allowed.


Comments

Popular posts from this blog

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -