Forum

> > CS2D > Scripts > JSON encode / decode in LUA?
Forums overviewCS2D overview Scripts overviewLog in to reply

English JSON encode / decode in LUA?

7 replies
To the start Previous 1 Next To the start

old JSON encode / decode in LUA?

Marcell
Super User Off Offline

Quote
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?

old Re: JSON encode / decode in LUA?

Marcell
Super User Off Offline

Quote
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()
edited 1×, last 21.08.17 04:52:28 pm

old Re: JSON encode / decode in LUA?

Marcell
Super User Off Offline

Quote
@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

old Re: JSON encode / decode in LUA?

Marcell
Super User Off Offline

Quote
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.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview