flutter access json object inside object
To access a JSON object inside another JSON object in Flutter, you can use the dot notation or square bracket notation. Here's an example:
// Assuming you have a JSON object like this:
var data = {
"person": {
"name": "John",
"age": 30
}
};
// Accessing the name property using dot notation
var name = data["person"]["name"];
print(name); // Output: John
// Accessing the age property using square bracket notation
var age = data["person"]["age"];
print(age); // Output: 30
In the example above, we have a JSON object called data
with a nested object called person
. To access the properties inside the nested object, we use either the dot notation (data.person.name
) or the square bracket notation (data["person"]["name"]
).
Please note that the actual implementation may vary depending on your specific use case and the structure of your JSON data.