I have a JSON like below comes from the server side:
{
movie:
{
title : String?,
description: String?,
id: String?,
image: String?,
videos :
[
video[i]:
{
trailers:
[
trailers[i]:
{
title:String?
option1: String?,
option2: String?,
option3: String?,
availables: List<bool>?,
},
]
},
]
}
}
I am trying to create a models/movie
class that can receive and handle such a JSON variable. What I have done so far is the easy part:
class Movie with ChangeNotifier {
String id;
String? title;
String? image;
List<Map<String,dynamic>>? videos;
}
I don’t know how to continue and define the sub variables of the videos
?
EDIT
I don’t have access to the real data at the moment but the JSON would be like the following I think:
{
"movie":
{
"title" : "String",
"description": "String",
"id": "String",
"image": "String",
"videos" :
[
"video":
{
"trailers":
[
"trailers":
{
"title":"String",
"option1": "String",
"option2": "String",
"option3": "String",
"availables":
{
"first": true,
"second": true,
"third": true,
},
},
],
},
],
},
}
2
Answers
May be you need this: Json to Dart Converter.
Try this website this is help you create model class according to your json response.
https://quicktype.io/
If any issue comment me i will provide you solutions.
The json you given is not valid json you can check it on json-validator online
i changed the json and make it valid here is the valid version
and the model for this is given as which i created using json to dart website