1

I have to Store Every Element of List to List so how i can do this?

Json Response as below.

{
  "responseCode": 200,
  "responseMessage": "OK",
  "data": null,
  "dataList": [
    "Technical",
    "Field"
  ],
  "excelDataList": null,
  "totalRecords": 2,
  "pageRecords": 0,
  "currentPageNumber": 1,
  "totalPages": 0
}

Here i have to store dataList values in list.

1 Answer 1

1

You first have to call jsonDecode to convert your String into deserialized data, then you can use the [] operator to access individual keys.

Read more at

import "dart:convert";

const String apiResult = """{
  "responseCode": 200,
  "responseMessage": "OK",
  "data": null,
  "dataList": [
    "Technical",
    "Field"
  ],
  "excelDataList": null,
  "totalRecords": 2,
  "pageRecords": 0,
  "currentPageNumber": 1,
  "totalPages": 0
}
""";

void main() {
  Map<String, dynamic> des = jsonDecode(apiResult);
  List<dynamic> data = des["dataList"];
  
  print(data);
}

which would print

> [Technical, Field]
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.