Forum

> > CS2D > Scripts > JSON encode / decode in LUA?
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch JSON encode / decode in LUA?

7 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt JSON encode / decode in LUA?

Marcell
Super User Off Offline

Zitieren
Hi!

Anybody knows if currently possible to encode/decode JSON in CS2D's lua right now? Myself currently would like to do a personal project but have no idea if it's possible right now. I mean there are BlitzMax modules for JSON, but of course, SQ or DC will not include JSON because I simply want this.

So wondering if there is any other way to include it with LUA?

alt Re: JSON encode / decode in LUA?

Marcell
Super User Off Offline

Zitieren
Thank both of you!

Edit:

Any idea what could do the crash of the server?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
local http = require("socket.http")
local ltn12 = require("ltn12")
json = require "sys\\lua\\json"



function sendRequest()

  local payload = [[ {
{
  "game": "TEST_GAME",
  "game_display_name": "My testing game",
  "icon_color_id": 5
} ]]


local response_headers, status = http.request { 
    url = "http://127.0.0.1:64620/game_metadata",
	method = "POST",
	 headers =
    {
      ["Content-Type"] = "application/json"
    },
    sink = ltn12.sink.table(payload)
}
end

sendRequest()
1× editiert, zuletzt 21.08.17 16:52:28

alt Re: JSON encode / decode in LUA?

Marcell
Super User Off Offline

Zitieren
@user Starkkz:

Yes, I have tried many ways, seems the code ran until

}
end

So basically I have no idea, what is the problem here.
I am running Windows with Dedicated Server

alt Re: JSON encode / decode in LUA?

Marcell
Super User Off Offline

Zitieren
Yes, I have tried to add
print ("Phrase 1...")
etc...
in different sections and seems each of them displayed, but the end of the code it crashes the server.

Yates told me to try first with Postman to see the response, which was nice, CS2D successfully added to SS3 App (as you can see: http://prntscr.com/gbaxbm)

But it did not work with the code above.
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht