Learn about the JSON properties and structure of device shadows in IoT Platform.
Example device shadow JSON document:
{
"state": {
"desired": {
"color": "RED",
"sequence": [
"RED",
"GREEN",
"BLUE"
]
},
"reported": {
"color": "GREEN"
}
},
"metadata": {
"desired": {
"color": {
"timestamp": 1469564492
},
"sequence": {
"timestamp": 1469564492
}
},
"reported": {
"color": {
"timestamp": 1469564492
}
}
},
"timestamp": 1469564492,
"version": 1
}
JSON properties are listed in JSON property description.
| Property | Description |
| desired | The desired device state. The desired section appears only when the device shadow has a desired state. Applications write to the desired section to update the state of a thing without a direct connection to the device. |
| reported | The reported device state. Devices write to the reported section to report their latest state. Applications read this section to get the device state. The reported section is optional. A device shadow is valid without the reported section. |
| metadata | When a user updates the device state document, the device shadow service automatically updates metadata. Each property in the device state has a timestamp in Epoch time, indicating when it was last updated. |
| timestamp | The time when the shadow document was last updated. |
| version | When a user actively updates the version number, the device shadow service checks whether the version value in the request exceeds the current version. If it does, the service updates the device shadow and sets version to the requested value. Otherwise, the request is rejected. The version increments on each update, ensuring you always modify the latest document version. The version parameter is a long type. To prevent overflow, pass |
Device shadows support arrays, but arrays must be updated in their entirety.
Example of updating array data:
- Initial state:
{ "reported" : { "colors" : [ "RED", "GREEN", "BLUE" ] } } - Update:
{ "reported" : { "colors" : [ "RED" ] } } - Final state:
{ "reported" : { "colors" : [ "RED" ] } }