Sep-10-2019, 01:08 PM
(Sep-10-2019, 10:26 AM)buran Wrote: what have you tried? Note that so called json that you have is not valid one. it looks like already converted to JSON object in python
thanks Buran,
i find out this solution
from collections import defaultdict data = [{'_id': '1', 'date': '2019-09-07', 'name': 'abi', 'value': 0, 'unit': '°C'}, {'_id': '2', 'date': '2019-09-08', 'name': 'allo', 'value': 3, 'unit': '°F'}, {'_id': '3', 'date': '2019-09-09', 'name': 'ali', 'value': 0, 'unit': '°C'}] result = defaultdict(list) for i in data: for k, v in i.items(): result[k].append(v) print(result)