Learn Courses My Dashboard

List wouldn't show anything when add INT to Models

I have data from json for the ListView. But When I add INT to the Models, It show empty value on preview. Does anyone has any idea? Thank you.

struct AppetizersView: View {
    @ObservedObject var amodel = AModel()
    @Environment(\.presentationMode) var mode: Binding<PresentationMode>
    var body: some View {
        List(amodel.arecipes) { a in
                destination: AppetizersDetailView(arecipe:a),
                label: {
                    HStack {
                            .frame(width: 120, height: 90)
                        VStack(alignment: .leading, spacing: 8) {
                            tags(tags: a.postType)
                            Text("Happy Kitchen")
                            HStack {
                                Stars(star: a.stars)
    .navigationBarTitle("Appetizers",displayMode: .inline)
    .navigationBarItems(leading: Button(action : {
                        Image(systemName: "arrow.left")
struct AppetizersView_Previews: PreviewProvider {
    static var previews: some View {

struct tags: View {
    var tags: Array<String>
    var body: some View {
        HStack {
            ForEach(tags, id: \.self) { e in
                .font(.system(size: 6))
                   RoundedRectangle(cornerRadius: 10)
                    .stroke(Color.pink, lineWidth: 0.5)

struct Stars: View {
    var star: Int
    var body: some View {
        HStack(spacing: 5) {
            ForEach(1...star, id: \.self) { e in
                Image(systemName: "star.fill")
            if star < 5 {
                let e = 5 - star
                ForEach(1...e, id: \.self) { e in
                    Image(systemName: "star.fill")


import Foundation

class ARecipe: Identifiable, Decodable {
    var aid:UUID?
    var name:String
    var image:String
    var description:String
    var prepTime:String
    var cookTime:String
    var totalTime:String
    var servings:String
    var stars:Int
    var postType:Array<String>
    var ingredients:[String]
    var directions:[String]

json file

        "name": "Beef Chow Fun",
        "image" : "beef chow fun",
        "description": "Baked eggplant with bread crumbs and lots of cheese. Delicious!",
        "prepTime": "25 minutes",
        "cookTime": "35 minutes",
        "totalTime": "1 hour",
        "servings": "10",
        "stars": 5
        "postType": ["iOS","SwiftUI", "Xcode"],
        "ingredients": [
            "500g flat rice noodles",
            "150g beef",
            "1/2 onion",
            "120g bean sprouts",
            "2 tablespoons of light soy sauce",
            "1 tablespoon dark soy sauce",
            "1/2 teaspoon salt",
            "1 teaspoon sugar",
            "Marinades: 2 1/2 teaspoons light soy sauce, 1/4 teaspoon dark soy sauce, 1 teaspoon corn flour, 3/4 teaspoon sugar, 2 teaspoons water, 1/2 teaspoon sesame oil"
        "directions": [
            "Wash the beef first and drain the water. Cut into thin slices horizontally, marinate in the marinade for about 15 minutes, set aside.",
            "Heat the oil in a wok, pan-fried the beef on both sides over medium-high heat until it is eighty mature, and then set aside.",
            "Heat the wok again, add onions and fry until soft. Add the bean sprouts and stir-fry until cooked, add the flat rice noodles into wok, stir-fry all the ingredients well. Add the seasonings and stir well. Finally, pour the beef and mix well. Serve."

For one thing, your JSON is invalid. You need a comma after the value for "stars".

Also, for questions like this it helps to show the code where you are decoding the JSON.

Oh damn. That small mistake. Sorry for this stupid question.
Once again, thank you for your help roosterboy.