This is an extension that implements Json API for SourceMod based on Jansson
- Windows
- Linux
- Any
- Go on releases
- Download release for your OS
- Unpack on your dedicated game server
- Congratulation 🥳
// if u need to use simple json builder
#define JSON_INCLUDE_BUILDER
// lib
#include <jansson>
// some func
public void OnMapStart() {
// empty JsonObject
Json jsonObject = new Json("{}");
// empty JsonArray
Json jsonArray = new Json("[]");
// {
// "array": [
//
// ]
// }
asJSONO(jsonObject).Set("array", jsonArray);
delete jsonArray;
// simple builder
jsonObject = asJSONB(jsonObject)
.SetInt("int", 12)
.SetString("string", "rejchev")
.SetFloat("float", 111.111)
.SetInt64("int64", "9999999999999")
.Build();
// ...
char buffer[1024];
if(!jsonObject.Dump(buffer, sizeof(buffer), JsonPretty(4)|JsonRealPrecision(3), true))
delete jsonObject;
LogMessage(buffer);
// output:
//
// {
// "array": [
//
// ],
// "int": 12,
// "string": "rejchev",
// "float": 111.111,
// "int64": 9999999999999
// }
}
Another example: test.sp
More information: jansson.inc
#include <IJansson.h>
nJansson::IJansson* g_pJansson = nullptr;
void Sample::SDK_OnAllLoaded()
{
SM_GET_LATE_IFACE(JANSSON, g_pJansson);
}
Header: IJansson.h
More information: SourceMod WiKi
Distributed under the GPL-3.0 License. See LICENSE.txt
for more information.
- @On DiscordServer -
rej.chev
- @On GitHub