Learn what Felgo offers to help your business succeed. Start your free evaluation today! Felgo for Your Business

Forums

OverviewFelgo 2 Support (Qt 5) › How to Model this JSON data?

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #23992

    Jufry

    I have been looking for a solution everywhere, but I can’t find it. So I better ask directly here. Hope someone can help me.

    I want to create an application with JSON data. I divided the data by date. But I don’t know how to make a model for such data. all I know is the standard JSON model (according to the felgo and qt documents)

    Here’s my JSON file data:

    [
        {"05112020": [{"lbl:":"Outcome","total":"20000"},
                     {"lbl:":"Fee","total":"12000"},
                     {"lbl:":"Others","total":"66000"}]
        },
        {"06112020": [{"lbl:":"Outcome","total":"20000"},
                     {"lbl:":"Fee","total":"12000"},
                     {"lbl:":"Others","total":"66000"}]
        }
    ]

    this is my code:

        AppListView {
            id: lv_hariIni
            model: jsonModel // this is from JsonListModel
            anchors.top: txt_hariIni.bottom
            height: contentHeight
            delegate: AppListItem {
                height: leftItem.height
                leftItem: AppText {
                    text: model["05112020"].lbl // "05112020" is Manual key for test
                    verticalAlignment: Text.AlignVCenter
                    padding: dp(8)
                }
                rightItem: AppText {
                    text: model["05112020"].total
                    verticalAlignment: Text.AlignVCenter
                    padding: dp(8)
                }
                showDisclosure: true
            }
        }

    The result is “undefined

    Thanks before and sorry I am new in Felgo

    #23993

    Marcin

    Hi Jufry,
    Don’t you store the date data as array first?
    So not

    model["05112020"].lbl
    
    

    but:

    model["05112020"][0]["lbl:"]

    Does it help?

    Plus, is everything ok with lbl key formatting? It look like the “:” should not be part of “lbl” key.

Viewing 2 posts - 1 through 2 (of 2 total)

RSS feed for this thread

You must be logged in to reply to this topic.

Qt_Technology_Partner_RGB_475 Qt_Service_Partner_RGB_475_padded