     return lhs.startDate == rhs.startDate && lhs.value == rhs.value
 }
 
-
-public class DailyValueSchedule {
+extension RepeatingScheduleValue: RawRepresentable {
+    public typealias RawValue = [String: AnyObject]
+
+    public init?(rawValue: RawValue) {
+        guard let startTime = rawValue["startTime"] as? Double,
+            value = rawValue["value"] as? Double else {
+                return nil
+        }
+
+        self.init(startTime: startTime, value: value)
+    }
+
+    public var rawValue: RawValue {
+        return [
+            "startTime": startTime,
+            "value": value
+        ]
+    }
+}
+
+
+public class DailyValueSchedule: RawRepresentable {
+    public typealias RawValue = [String: AnyObject]
+
     private let referenceTimeInterval: NSTimeInterval
     private let repeatInterval = NSTimeInterval(hours: 24)
 

        }

        referenceTimeInterval = firstItem.startTime
    }

    private var maxTimeInterval: NSTimeInterval {

        self.unit = unit

        super.init(dailyItems: dailyItems, timeZone: timeZone)
    }

    public required convenience init?(rawValue: RawValue) {
        guard let
            rawUnit = rawValue["unit"] as? String,
            timeZoneName = rawValue["timeZone"] as? String,
            rawItems = rawValue["items"] as? [RepeatingScheduleValue.RawValue] else
        {
            return nil
        }

        self.init(unit: HKUnit(fromString: rawUnit), dailyItems: rawItems.flatMap { RepeatingScheduleValue(rawValue: $0) }, timeZone: NSTimeZone(name: timeZoneName))
    }

    public func at(time: NSDate) -> HKQuantity {
