JSON data to display in the list

I saw the similar topic - but asking here again.

My app gets a response from server, it is JSON array and each array item contains:

Player1ID, Player2ID, MatchDate/Time, CourtID

I want to display this is the collection.

I probably need to do it over helper table, but how to parse JSON into my items? I am not aware of any JSON parser in Glide.

Thanks

Yes, you will need to use a Helper Table with numbered rows.
You can use the JSON Query column to extract the object properties.
If you have any problems, share a sample of the JSON and somebody will help.

2 Likes

I created helper table, received my json, but struggling to convert JSON array into Glide array. I tried js column but it seems that Glide doesn’t allow returning array so Glide creates array column.

I tried split text '},{" but I feel there might be some better and cleaner solution.

@Darren_Murphy , please help :slight_smile:

Here is my json that I need to convert to Glide array in helper table:

[
    {
        "player1ID": "dnDEeNNPQNyEhCGpaAyBhQ",
        "player2ID": "tHGxFNjDQl2YkPd0ga2ZYQ",
        "dayPlayed": "1",
        "hourPlayed": "15",
        "courtID": "vIMfQHxSaJFU8ogpAr0v"
    },
    {
        "player1ID": "Od9fmlcnSvWKXjhr9WrJpQ",
        "player2ID": "LDY-2YUXQj2feUUgE57xQw",
        "dayPlayed": "3",
        "hourPlayed": "18",
        "courtID": "Zk6uhkn9YXzh123c7Pra"
    },
    {
        "player1ID": "NEpViJIiTcmloNcihgkANQ",
        "player2ID": "a-y0ruSKNQguwK-4x5.VUyQw",
        "dayPlayed": "2",
        "hourPlayed": "20",
        "courtID": "BG4G07LVpEvs5c9Bc3SI"
    }
]
let json = JSON.parse(p1);
return json[p2].player1ID;

Obviously you’ll need a separate column for each value.
You could also use the Query JSON column, but I find it just as easy to use JavaScript for simple cases like this.

1 Like

I know this but need to create array out of json as i use the array for dynamic number of rows in helper table as per you helper table help

I currently made it work by splitting json array with } into array and then got helper rows each containing a single match

oh, sorry I misunderstood. Do you mean like this?

let json = JSON.parse(p1);
return JSON.stringify(json[p2])

2 Likes

Very elegant. thanks