splewis / get5

CS:GO Sourcemod plugin for competitive matches/scrims
GNU General Public License v3.0
557 stars 175 forks source link

get5_loadmatch_url "Invalid <JSON Object> handle 0 (error 4)" #329

Closed j4grmeister closed 5 years ago

j4grmeister commented 5 years ago

Expected behavior

I'm trying to use get5_loadmatch_url to load a JSON file from my own application. The JSON returned by my application through get5's GET request is valid JSON. I have attached the remote_config0.json file that get5 retrieves from my application as a .txt. remote_config0.txt

After using get5_loadmatch_url "my_apps_url" I initially got an error saying that the SMJansson extension was required.

Actual behavior

I took the latest smjansson.ext.so from https://github.com/thraaawn/SMJansson/tree/master/bin and put it into my server's addons/sourcemod/extensions. After that I was confronted by the following error when I tried get5_loadmatch_url again:

L 01/07/2019 - 16:57:51: [SM] Exception reported: Invalid <JSON Object> handle 0 (error 4) L 01/07/2019 - 16:57:51: [SM] Blaming: get5.smx L 01/07/2019 - 16:57:51: [SM] Call stack trace: L 01/07/2019 - 16:57:51: [SM] [0] json_typeof L 01/07/2019 - 16:57:51: [SM] [1] Line 1028, /home/splewis/sm-1.8/scripting/include/smjansson.inc::json_object_get_string L 01/07/2019 - 16:57:51: [SM] [2] Line 94, ./scripting/get5/jsonhelpers.sp::AddJsonAuthsToList L 01/07/2019 - 16:57:51: [SM] [3] Line 560, ./scripting/get5/matchconfig.sp::LoadTeamDataJson L 01/07/2019 - 16:57:51: [SM] [4] Line 508, ./scripting/get5/matchconfig.sp::LoadMatchFromJson L 01/07/2019 - 16:57:51: [SM] [5] Line 158, ./scripting/get5/matchconfig.sp::LoadMatchFile L 01/07/2019 - 16:57:51: [SM] [6] Line 47, ./scripting/get5/matchconfig.sp::LoadMatchConfig L 01/07/2019 - 16:57:51: [SM] [7] Line 255, ./scripting/get5/matchconfig.sp::SteamWorks_OnMatchConfigReceived

I guess I'm not exactly sure how to remedy the problem or if it's something I'm doing wrong. Any help would be appreciated :)

splewis commented 5 years ago

I don't see anything obviously wrong with what you're doing (the json config looks fine). It's probably a bug in get5 0.6.0, though I haven't verified that yet.

I'd suggest trying a recent development build of get5. Newer commits remove the use of the smjansson extension entirely, so the json parsing is done differently now. You can download one from the link at https://github.com/splewis/get5#download. I expect to release a 0.7.0 soonish with those changes.

j4grmeister commented 5 years ago

That worked! Thank you.

I did get an error from my JSON because i had team2.players as an empty dict. That's really my own problem though and now I just remove that key if it is empty. Just a note to other users though.