1

I have a string i want to create the list using the below string and also I can't convert this string into a JSON string

String s = "[{emp_username: gg, emp_designation: ty, emp_contact: hh, emp_email: yy, emp_address: hu}]";

1 Answers1

1

Try the following code:

import 'dart:convert';

void main() {
  String s = "[{emp_username: gg, emp_designation: ty, emp_contact: hh, emp_email: yy, emp_address: hu}]";

  dynamic result = jsonDecode(s
      .replaceAll("{", '{"')
      .replaceAll("}", '"}')
      .replaceAll(": ", '": "')
      .replaceAll(", ", '", "'));

  print(result); // [{emp_username: gg, emp_designation: ty, emp_contact: hh, emp_email: yy, emp_address: hu}]
}
My Car
  • 4,198
  • 5
  • 17
  • 50