I need to append 2 JSON.
Currently it is printing as two separate Json.
How do I combine both of my reading???? I want Bothe readings in one JSON
Console:
Currently it is printing as two separate Json.
How do I combine both of my reading???? I want Bothe readings in one JSON
Code Block let query = HKSampleQuery(sampleType: glucoseType!, predicate: predicate, limit: 5, sortDescriptors: nil) { (query, results, error) in for result in results as! [HKQuantitySample] { let bloodGlucose = result.quantity.description let bloodGlucoseItem = HealthDataItem(endDate: result.endDate, value: String(bloodGlucose), startDate: result.endDate, type: .bloodGlucose) let healthData = [bloodGlucoseItem] do { let data = try JSONEncoder().encode(healthData) let json = String(data: data, encoding: String.Encoding.utf8) print("json data:", json as Any ) resolve(json) } catch { //error handling } } }
Console:
Code Block json data: Optional("[{\"value\":\"9 mg\\/dL\",\"endDate\":635308200,\"startDate\":635308200,\"type\":\"bloodGlucose\"}]") json data: Optional("[{\"value\":\"4 mg\\/dL\",\"endDate\":635311800,\"startDate\":635311800,\"type\":\"bloodGlucose\"}]")