def toActuatorDataFromJson(self, string): act = ActuatorData() data = json.loads(string) logging.info(data) act.name = data['name'] act.value = data['current'] act.command = data['command'] act.min_value = data['min_value'] act.max_value = data['max_value'] act.total_value = data['total_value'] act.avgTemp = data['avgTemp'] act.timestamp = data['timestamp'] logging.info("New actuator generated from JSon \n") return act
def toActuatorDataFromJson(self, jsonStr) -> ActuatorData: #instantiate ActuatorData actuatorData = ActuatorData() #use json load to convert it to a dictionary jsonLoad = json.loads(jsonStr) #parse and add it to the actuatorData object one by one actuatorData.name = jsonLoad['name'] actuatorData.command = jsonLoad['command'] actuatorData.value = jsonLoad['value'] #return the actuatorData reference return actuatorData