I am trying to jsonEncode a list in Flutter.
List<String> _list = ["name1", "name2"]
Things I tried:
jsonEncode(_list);
jsonEncode(_list.map((e) => e.toString()).toList());
This gives me a Json String however the data I get is:
"[\"name1\",\"name2\"]"
I want to send the data so that it shows:
{
0: "name1",
1: "name2"
}
PS: I am using Realtime Firebase Database for backend.
You can not have an Integer as a key in a valid Json Object. This is possible in JS, but not in the Json spec.