Class: AwsIotDevice::MqttShadowClient::JSONPayloadParser

Inherits:
Object
  • Object
show all
Defined in:
lib/aws_iot_device/mqtt_shadow_client/json_payload_parser.rb

Instance Method Summary collapse

Constructor Details

#initializeJSONPayloadParser

This class acts as Basic JSON parser. The answer from AWS is in a JSON format. All different key of the JSON file should be defined as hash key



13
14
15
# File 'lib/aws_iot_device/mqtt_shadow_client/json_payload_parser.rb', line 13

def initialize
  @message = {}
end

Instance Method Details

#get_attribute_value(key) ⇒ Object



21
22
23
# File 'lib/aws_iot_device/mqtt_shadow_client/json_payload_parser.rb', line 21

def get_attribute_value(key)
  @message[key]
end

#get_jsonObject



29
30
31
# File 'lib/aws_iot_device/mqtt_shadow_client/json_payload_parser.rb', line 29

def get_json
  @message.to_json
end

#set_attribute_value(key, value) ⇒ Object



25
26
27
# File 'lib/aws_iot_device/mqtt_shadow_client/json_payload_parser.rb', line 25

def set_attribute_value(key, value)
  @message[key] = value
end

#set_message(message) ⇒ Object



17
18
19
# File 'lib/aws_iot_device/mqtt_shadow_client/json_payload_parser.rb', line 17

def set_message(message)
  @message = JSON.parse(message)
end