1

I am attempting to create a Flutter app that reads JSON data and outputs to a listview. Below I have typed out a short example of my data.

Currently I am grabbing my data using:

Future<String> getJsonData() async {
var response = await rootBundle.loadString('assests/data/test.json');

this.setState(() {
  var convertDataToJson = json.decode(response);
  data = convertDataToJson;
});

I am then outputting my data using:

child: new Text(data[index]['text'])

How do I output the name of the Manager object that is stored?

  _id: 397134856770953216
  text: "This is the text that is stored"
  Manager: Object
      uName: "Username"
      name: "Real Name"
  Client: Object
      uName:"Second Username"
      name:"Second Real Name"
1
  • No way to tell without seeing the content of assests/data/test.json. Commented Nov 5, 2018 at 17:58

1 Answer 1

1

You can easily access it by:

String managerName = data['Manager']['uName'];
print(managerName);

It will work.

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.