skip to Main Content

Unable to parse Json in Flutter

I used to parse JSON to list of objects by the following way: final response = await api(map); var raw = jsonDecode(response.body)[0]; dataList = parseJson(raw["datalist"]); List<dataRecord> parseJson(String responseBody) { final parsed = convert.jsonDecode(responseBody).cast<Map<String, dynamic>>(); return parsed.map<dataRecord>((json) => dataRecord.fromJson(json)).toList(); } and…

VIEW QUESTION

Json – Group and Sum value with JQ

I've got a file with these jsons: {"count":42,"day":"2023-06-22","id":"123"} {"count":12,"day":"2023-06-22","id":"456"} {"count":23,"day":"2023-06-23","id":"123"} {"count":44,"day":"2023-06-23","id":"789"} {"count":65,"day":"2023-06-21","id":"456"} Actually I don't care about the day and want to group my records by id and sum the count. Expected result: {"id":"123","count":65} {"id":"456","count":77} {"id":"789","count":44} How would I achieve…

VIEW QUESTION
Back To Top
Search