Hello everyone !
I try to implement a JSON loading of datas for the level's datas of my game.
But, I encounter a strange issue.
If I use the wiki example for JSON, it works great.
But when I've tried to modify the example for my own usage, I didn't achieve to make it works.
So, after a lot of try and fails, I just tried to make the wiki example work with a different value for the JSON url... without success.
Here is the wiki example :
https://wiki.giderosmobile.com/index.php/Json
require('json')
local loader = UrlLoader.new("<a href="http://ip-api.com/json" rel="nofollow">http://ip-api.com/json</a>")
loader:addEventListener(Event.COMPLETE, function(event)
local receivedTable=json.decode(event.data)
print(receivedTable.countryCode)
print(receivedTable.timezone)
end) |
Here are the urls I tried :
http://ip-api.com/json (work)
https://jimlev.alwaysdata.net/test.json (error : Expected value but found T_END at character 1)
http://jsonkeeper.com/b/UIDW (error : Expected value but found invalid token at character 1)
Anything I miss ?
Comments
eg, on the line just after loader, put this:
Likes: MoKaLux, jimlev
https://deluxepixel.com
I tried your additions in my code. That confirm what I was thinking : the code is ok, but the way / place the json is hosted seems to be the problem.
I explain :
http://ip-api.com/json >>> with that host, the dump gives me... the json content.
https://jimlev.alwaysdata.net/test.json >>> on that url, nothing happen : no errors, no message, dump do nothing. If I change the url from https to http, I still have an error "Expected value but found T_END at character"
http://jsonkeeper.com/b/UIDW >>> on that one, the dump gives me... an HTML header!!! how is it possible, I don't know but, in that case, now it's clear that the error ("invalid token at character 1") is given because of the < (first character of the HTML page).
I'm going to investigate a bit more.
SinisterSoft : could you, please, explain me briefly what is the use of that line ?
Likes: SinisterSoft
SinisterSoft: “ I don't create classes that much - classes are good for making things simpler but imho for frame rate they are also death by a thousand cuts.”
Totebo: “ Best quote ever.”
🤔
This line simply simplifies the writing of the code, for example he assigns local upper to string.upper so this will shorten your code and your typing.
EDIT: and as mentioned below will speed up your code
Likes: SinisterSoft
http://lua-users.org/wiki/OptimisingUsingLocalVariables
http://kiki.to/blog/2014/04/04/rule-3-allow-monkeypatching/
Likes: MoKaLux
Likes: MoKaLux
Fragmenter - animated loop machine and IKONOMIKON - the memory game
https://devforum.roblox.com/t/should-i-be-localizing-these-variablesfunctions/568955
is it?
Likes: MoKaLux
Fragmenter - animated loop machine and IKONOMIKON - the memory game
Likes: MoKaLux
SinisterSoft: “ I don't create classes that much - classes are good for making things simpler but imho for frame rate they are also death by a thousand cuts.”
Totebo: “ Best quote ever.”
🤔
@keszegh I'm not sure if getting the pointer to the function then calling that is still faster or maybe slower or the same speed in Luau. I can try do some tests though once @hgy29 does a new test build.
Likes: keszegh
https://deluxepixel.com
First of all, I didn't achieve to correct the httpS issue. I added the .dll files t my Gideros folder but with no result.
When I try to load the JSON from non-https, the dump show that it's the redirect
ex.:
local loader = UrlLoader.new("http://jsonkeeper.com/b/UIDW")
gives :
"301 Moved Permanently..."
I'm just surprised that the jsonkeeper service, which is made to deliver properly JSON files is not able to deliver through http and only https.
I will also probably search for a SQL solution which can be a good alternative, may be more documented...
SinisterSoft: “ I don't create classes that much - classes are good for making things simpler but imho for frame rate they are also death by a thousand cuts.”
Totebo: “ Best quote ever.”
🤔
SinisterSoft: “ I don't create classes that much - classes are good for making things simpler but imho for frame rate they are also death by a thousand cuts.”
Totebo: “ Best quote ever.”
🤔
SinisterSoft: “ I don't create classes that much - classes are good for making things simpler but imho for frame rate they are also death by a thousand cuts.”
Totebo: “ Best quote ever.”
🤔
It still makes an error on gideros player on desktop but, when I try it on gideros player on my mobile, it works great.
Now, I try to make the HTML5 export works but I have an error and I think it's still that damn JSON plugin.
Here is the message I get :
Oops, something went wrong...
An unexpected error occuredThe details below may be helpful to you or the app developer... hopefully.
exception thrown: TypeError: what.includes is not a function
Error can be seen here : https://jimlev.alwaysdata.net/game/RapidoQuizz/
It's the first time I use a plug-in with gideros. Do I need to add some files to the export folder ? I added the
Edit1: on export, I tried with Compression setting On and Off, PWA check or not, etc...
SinisterSoft: “ I don't create classes that much - classes are good for making things simpler but imho for frame rate they are also death by a thousand cuts.”
Totebo: “ Best quote ever.”
🤔
SinisterSoft: “ I don't create classes that much - classes are good for making things simpler but imho for frame rate they are also death by a thousand cuts.”
Totebo: “ Best quote ever.”
🤔
Likes: MoKaLux, SinisterSoft
Now, I achieved to make something with my first JSON loading. It works and give me the params I need... But now, it's the second one who gives me an error... I'm going mad.
edit :
It's aliiiiivvve.hum hum... problem found. It worksSinisterSoft: “ I don't create classes that much - classes are good for making things simpler but imho for frame rate they are also death by a thousand cuts.”
Totebo: “ Best quote ever.”
🤔