How to pass json array and its object and keys of object in flutter.?
1,006
The JSON you have added isn't valid
If this is the JSON you want to parse -
{
"rows": [{
"Task": {
"title": "aamir"
},
"Category Type": {
"id": "123"
}
}]
}
You can parse it like this -
for(int i = 0 ; i < rows.length ; i++) {
var task = rows[i]["Task"];
String title = task["title"];
String id = rows[i]["Category Type"]["id"];
Author by
aamir faisal
Updated on December 10, 2022Comments
-
aamir faisal over 1 year
[enter image description here][1]I want to parse json Array and its object and keys in object of array.? how can i parse.?
http.Response response=await http.get("api url"); List resJson=json.decode(response.body); Map decode=jsonDecode(response.body); List<Task> task =new List<Task>(); for(var task in decode['rows']){ print(task['Task']); }
i want to parse this array..
"rows":[ { "Task" { "title":"aamir" },"Category Type":{ id:"123" } { "number":3, "word":"SES" } ] }
-
aamir faisal about 5 yearshow can i get "rows".?
-
Keerti Purswani about 5 years
var respBody = jsonDecode(response?.body); var rows = respBody["rows"];
-
Keerti Purswani about 5 yearsIf your problem is solved, I would suggest you to mark the answer which helped. :)