Echo JSON string
3 replies



19.04.20 07:02:19 am
Guys, is there any ways to echo the JSON string using
echo ?
Output in console should be like: {"key":"value"}

Output in console should be like: {"key":"value"}
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.
The point is I cam not echo the quote with
echo
Does the print or io.write of lua can output to cs2d_dedicated console?

Does the print or io.write of lua can output to cs2d_dedicated console?
First, download this JSON.lua then place it in sys/lua.
The usage is something like this
You'll get output similar (the key-value is not ordered) like this
print and io.write can write to cs2d_dedicated console yes.
The usage is something like this
Code:
1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
local JSON = require("JSON")
local data = {
hello = "World",
another = "World",
MikuAuahDark = "Test"
}
print(JSON:encode(data))
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
Code:
1
{"hello":"World","another":"World","MikuAuahDark":"Test"}
print and io.write can write to cs2d_dedicated console yes.





