Azure / azure-iot-sdk-csharp

A C# SDK for connecting devices to Microsoft Azure IoT services
Other
463 stars 493 forks source link

Remove "key" and "value" keys from returned json #3388

Closed patilsnr closed 10 months ago

patilsnr commented 10 months ago

TwinProperties.ToJson() will now return something like this:

{
  "properties" : {
      "desired" : {
           "myProp" : "myValue",
           "$version" : 3
      },
     "reported" : {
            "myProp" : "myValue",
           "$version" : 4
     }
   }
}
varunpuranik commented 10 months ago

What issue does this address, and why is the new way better than the old one?

rido-min commented 10 months ago

Why $version is not a field? where is the $version for reported?

The Json should be something like:

{
  "properties" : {
      "desired" : {
           "myProp" : "myValue",
           "$version" : 3
      },
     "reported" : {
            "myProp" : "myValue",
           "$version" : 4
     }
   }
}
patilsnr commented 10 months ago

What issue does this address, and why is the new way better than the old one?

My understanding is that this is consistent with what the V1 API returns. Without this fix an extra level of serialization exists where "key" and "value" are literally written into the json object

patilsnr commented 10 months ago

/azp run

azure-pipelines[bot] commented 10 months ago
Azure Pipelines successfully started running 1 pipeline(s).
patilsnr commented 10 months ago

/azp run

azure-pipelines[bot] commented 10 months ago
Azure Pipelines successfully started running 1 pipeline(s).
varunpuranik commented 10 months ago

What issue does this address, and why is the new way better than the old one?

My understanding is that this is consistent with what the V1 API returns. Without this fix an extra level of serialization exists where "key" and "value" are literally written into the json object

What is returned by IoT Hub?

patilsnr commented 10 months ago

What issue does this address, and why is the new way better than the old one?

My understanding is that this is consistent with what the V1 API returns. Without this fix an extra level of serialization exists where "key" and "value" are literally written into the json object

What is returned by IoT Hub?

Running a quick test with a device in my own Hub, I get:

{\"properties\":{\"desired\":{\"$version\":1},\"reported\":{\"$version\":1}}} which looks more in line with the desired format. @rido-min could you please verify?

patilsnr commented 10 months ago

/azp run

azure-pipelines[bot] commented 10 months ago
Azure Pipelines successfully started running 1 pipeline(s).