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}]";
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}]";
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}]
}