List<Employee> employees = [
Employee(
id: 1,
name: 'John',
department: 'HR',
),
Employee(
id: 2,
name: 'Alice',
department: 'IT',
),
];
String strEmployees = jsonEncode(
employees.map((e) => e.toJson()).toList(),
);
print(strEmployees );
Comments 0