I am using the com.microsoft.azure.sdk.iot:iot-service-client:1.16.0
library (Java) for working with Azure IoT Devices. I am trying to "update" some properties, however they nested and I am having trouble updating them.
My DeviceTwin Json looks like this:
The azure library comes with a setDesiredProperties
function that takes a HashSet<Pair>
as its argument. So I can easily update `firmwareVersionToDownload" , "serverConfigurationVersion", or "webContentDataType" keys because they are Top-Level entities, like this (as seen in the image above):
myIotDeviceObjectInJava.setDesiredProperties(new HashSet<Pair>() {{
add(new Pair("myKey", "myNewValueForKey"));
}});
I need to set the value for the keys "object1" & "object2" to the value of "null", but they are 2/3 levels deep. Can anyone help me to do this?
I've tried creating a new HashSet with other nested HashSet's until I reached the level (third) where I then passed in a new Pair("object1","null") object to set to null, but it ended up just deleting my entire "serverConfiguration"
block of code (example below):
updateProperties(new HashSet<Pair>() {{
add(new Pair("serverConfiguration", new HashSet<Pair>() {{
add(new Pair("nestedIpData1",new HashSet<Pair>() {{
add(new Pair("object1","null"));
}}));
}}));
}}
);
Do I need to iterate over the top level objects and get the value object of serverConfiguration
and then set it somehow that way?