Forum

> > CS2D > Scripts > Echo JSON string
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch Echo JSON string

3 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt Echo JSON string

Devil-Thanh
GAME BANNED Off Offline

Zitieren
Guys, is there any ways to echo the JSON string using cs2d cmd echo ?

Output in console should be like: {"key":"value"}

alt Re: Echo JSON string

VADemon
User Off Offline

Zitieren
If you have the JSON as a string you can output it already. If you have a table with data then use any JSON library to encode the data as JSON and then print it.

alt Re: Echo JSON string

Devil-Thanh
GAME BANNED Off Offline

Zitieren
The point is I cam not echo the quote with cs2d cmd echo
Does the print or io.write of lua can output to cs2d_dedicated console?

alt Re: Echo JSON string

MikuAuahDark
User Off Offline

Zitieren
First, download this JSON.lua then place it in sys/lua.

The usage is something like this

1
2
3
4
5
6
7
8
local JSON = require("JSON")

local data = {
	hello = "World",
	another = "World",
	MikuAuahDark = "Test"
}
print(JSON:encode(data))

You'll get output similar (the key-value is not ordered) like this
1
{"hello":"World","another":"World","MikuAuahDark":"Test"}

print and io.write can write to cs2d_dedicated console yes.
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht