Operation retrieving a json file online

I want to read a json file online from a database and select the maximum value of trackid and do +1 and add in another label!

i need an help to select all the values of trackid and take the major! i am playng without success with lists!

and recieve:

solved via database for obtain the maximum value:
SELECT MAX(trackid) FROM my_table

now how i can clean the value “max” and add +1?

It is horrible but it works:

Here is the “json” if anyone else wants a go…


Thanks timai2…

As I wrote I solved the maximum value via database query… Now I try to understand from your blocks how to clean my value of maximum value and add +1

The screen shot of the max query response does not balance its JSON brackets {}.
Can you grab the JSON and post it as text?

From what I see, the decode sequence would be …
set global dictResponse to decode json as dict (webResponseContent)
set global rowsWhatever to lookup by key “rows” in dictResponse
set global firstRowWhateverDict to select item 1 from global rowsWhatever
set global maxWhatever to lookup by key “max” from global firstRowWhateverDict
set global maxWhatever to global maxWhatever + 1 (edit)

I am betting rowsWhatever will never be empty. Add your own error checking.

i “cleaned” the json via a php file and i retrieve the cleaned value calling in web1 the php url

$url1 = "https://spatial.query.city/user/admin/api/v2/sql?q=SELECT%20MAX(trackid)%20FROM%20my_table";  //The url from where you are getting the contents
$risposta = (file_get_contents($url1)); //Converto in json string
$json1 = json_decode($risposta,true);
     foreach ($json1 ['rows'] as $rows)
    $output.="  ".$rows['max']." ";
    echo $output;

now i have in label1 text the value max! appinventor needs to know that is not a text but a number to do +1?

tryng this:

The proper way to do this is in the database table definition, as answered in your other thread

Two other approaches using some blocks from the dictionaries drawer:

Flatten the rows into a list with the list by walking key path block, which you could then use with the max operator in a loop to find the maximum value:


For the version where you’ve computed the max on the server, you can use the get value at key path to extract the value: