Home  • Programming • Dart

How to convert array of employee objects into array of json string in Dart?

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


Copyright © 2026. Powered by Intellect Software Ltd