title: azure-iot-sdk-c deserialize JSON payload
body: <p>I'm getting started with the Azure IoT SDK C-Library by using the <a href="https://github.com/Azure/azure-iot-sdk-c/blob/master/iothub_client/samples/iothub_client_sample_device_method/iothub_client_sample_device_method.c" rel="nofollow noreferrer">IoT_Hub Device Method samples</a>.</p>
  
  <p>Does anybody know if the SDK provides a function to deserialize the JSON message payload? There are some good <a href="https://github.com/Azure/azure-iot-sdk-c/blob/master/serializer/samples/simplesample_mqtt/simplesample_mqtt.c" rel="nofollow noreferrer">examples</a> for payload serialization to JSON, but I wasn't able to find the counterpart.</p>
  
  <p>I'm quite sure the SDK has some functionalities for JSON deserialization, e.g. something like:</p>
  
  <pre><code>BEGIN_NAMESPACE(WeatherStation);
  
  DECLARE_MODEL(ContosoAnemometer, 
    WITH_DATA(ascii_char_ptr, DeviceId), 
    WITH_DATA(int, WindSpeed), 
    WITH_DATA(float, Temperature), 
    WITH_DATA(float, Humidity), 
    WITH_ACTION(TurnFanOn)
  ); 
  
  END_NAMESPACE(WeatherStation);
  
  
  static int DeviceMethodCallback(const char* method_name, const unsigned char* payload, ...) 
  { 
      (void)userContextCallback; 
  
      ContosoAnemometer* myWeather = CREATE_MODEL_INSTANCE(WeatherStation, ContosoAnemometer);
      DESERIALIZE(myWeather, payload)
  
      printf("Device Id: %i\r\n", myWeather-&gt;DeviceId);
  
      // etc. etc.
  }
  </code></pre>