These two functions are working really fine for me in Windows, but when I tried to use them in the Android AppGameKit Player it says can't recognize the JSON structure (screen attached)
Maybe I'm doing something wrong, so any feedback is welcome
// Project: fromJSON
// Created: 2018-05-13
// show all errors
SetErrorMode(2)
// set window properties
SetWindowTitle( "fromJSON" )
SetWindowSize( 1024, 768, 0 )
SetWindowAllowResize( 1 ) // allow the user to resize the window
// set display properties
SetVirtualResolution( 1024, 768 ) // doesn't have to match the window
SetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devices
SetSyncRate( 30, 0 ) // 30fps instead of 60 to save battery
SetScissor( 0,0,0,0 ) // use the maximum available screen space, no black borders
UseNewDefaultFonts( 1 ) // since version 2.0.22 we can use nicer default fonts
type tApp
status as integer
title as string
version as string
endtype
global App as tApp
global response$ as string
response$ = ""
Save_JSON()
do
Print (response$ )
Print( ScreenFPS() )
Sync()
loop
function Save_JSON()
if GetInternetState()
http as integer
http = CreateHTTPConnection()
SetHTTPHost( http, "agkjson.firebaseio.com", 1 )
SetHTTPTimeout( http, 1000)
SendHTTPRequestASync( http, "/.json" )
while GetHTTPResponseReady(http) = 0
Print( "Connecting..." )
Sync()
endwhile
response$ = "Error"
if ( GetHTTPResponseReady(http) > 0 ) then response$ = GetHTTPResponse(http)
CloseHTTPConnection(http)
DeleteHTTPConnection(http)
if (len(response$) > 0)
OpenToWrite(1,"data/app.json",0)
WriteString(1,response$)
CloseFile(1)
endif
App.fromJSON( response$ )
endif
endfunction
The json structure
https://agkjson.firebaseio.com/.json
Using an array or an object I had the same result
http://www.nyan.cat/pirate