How can I get the text of inside the key?
I am able to use keys Using keys like this ..
print(myData[0]["1"].keys);
output: (a, b, c, d)
JSON File looks like this:
[
{
"1":{
"a": "text",
"b": "text",
"c": "text",
"d": "text"
}
}
]
I was able to get first key name using.. keys.first But I also want to get other keys name but when I use keys.second or keys.third that doesn't work. how else I can get key's text/name? thanks
keys is an iterable, so you can convert it to a List an access each key by its index:
//Will print 'd'
print(json[0]["1"].keys.toList()[3]);
or iterate over each one:
//Will print all the keys (a b c d)
json[0]["1"].keys.forEach((key){ print(key); });
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With