Assigning response to lvgl list


Hi Team,
i am getting response from my server in below way
i want display associations in lvgl list is it possible ?
and i don’t need any images in list i just want to display associations.
Please give me an example.
Thanks in Advance…

What MCU/Processor/Board and compiler are you using?


What LVGL version are you using?


What do you want to achieve?

i want display associations in lvgl list

I have done something similar where i have a list of things i want to make into individual buttons on the list.
I made a function which modified a char and set it to the first value the first value then the second and so on until the end is reached.

Be aware that even though it worked for me, I have renamed and removed a bit of code for your application, so I’m not 100% sure that it will work. You could probably also merge this two things into one but for me application i was the most convenient.
And I’m am very inexperienced with all of this programming business, but I hope i could help you

while (YourFunctionThatReturnsListName(char * AssociationsList, char * CharToModify, bool FirstCall) {
        list_btn = lv_list_add_btn  (YourList, NULL , CHarToModify);
        lv_obj_set_event_cb(list_btn, list_handler) //optional callback that handles clicks on the list elements
        FirstCall = false; 

This is the function I used to get the AssociationsList elements:

bool YourFunctionThatReturnsListName(char * [] AssociationsList ,char * CharToModify, bool FirstCall)
    unsigned int SizeOfAssociationsList = sizeof(AssociationsList)/ sizeof(AssociationsList[0]) -1;
    static unsigned int Index ;
    if (FirstCall) {
        Index = 0;
    } // endif
    if (Index > SizeOfAssociationsList) {
        return false;
    } // endif
    return true;

Thank you Rhaoma.

Actual way of initializing array is char array[]={“abcd”,“efgh”,“ijkl”,“mnop”};
but in my case the array is [“abcd”,“efgh”,“ijkl”,“mnop”] so how to implement this type of array to lvgl list

In what form do you get the response? Is it just plain text, or is it an array where you can access each individual element? If you can access each element couldn’t you just transfer it into a char array[] or whatever will work. But if its plain text I would think that you would have to devise a method that can “recognize” the elements of the text you want, that could potentially be tricky I am not too sure

i am getting response in JSON form like below
but i want to show only associations in lvgl list i.e.,[“abcd”,“efgh”,“ijkl”,“mnop”]

Well I have no experience with JSON but after poking a bit around it seems that you should be able to convert your response to char, but there are probably many more qualified people here who can help you out.
Even though i don’t know how JSON works, I would like to try and figure it out with you. Is it text you get back, maybe like the equivalent of char?
I found this which may be something along the lines of what you need

It’s probably easiest to find a library that will let you parse JSON into an array of strings. Then you can create LVGL list elements based on that array of strings.