Raised This Month: $32 Target: $400
 8% 

[ANY] SMCereal - an Extension for JSON, XML, and Binary Serialization


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Atomicskullz
New Member
Join Date: Mar 2023
Location: United States
Old 03-31-2023 , 17:52   [ANY] SMCereal - an Extension for JSON, XML, and Binary Serialization
Reply With Quote #1

This extension adds serialization functionality to sourcemod. Not only JSON, but XML and binary too! It uses the C++ library Cereal.

Both JSON and XML archives can accept any primitive type, while binary can only accept integers.

I ensured that the include file was properly documented, so make sure to take a look!

Code:
char str[] = "CMake > AMBuild";

// You can also use the Xml_Archive and Binary_Archive functions
JsonArchive_SetString( 0, str ); //  index 0
JsonArchive_SetFloat( 1, 3.4 ); //  index 1
JsonArchive_SetInt( 2, 3.4 ); // index 2

char szFileName[512];
BuildPath( Path_SM, szFileName, sizeof( szFileName ), "data/example.json" )
	
JsonArchive_Serialize( szFileName );




JsonArchive_Deserialize( szFileName );

char szBuffer[128];

JsonArchive_GetString( 0, szBuffer, sizeof( szBuffer ) );

float flVal = JsonArchive_GetFloat( 1 );
int iVal = JsonArchive_GetNumber( 2 );
Source: https://github.com/Code4Cookie/SM-Cereal
Attached Files
File Type: dll sm_cereal.ext.dll (136.0 KB, 33 views)
File Type: so sm_cereal.ext.so (288.5 KB, 33 views)
File Type: inc cereal.inc (4.7 KB, 43 views)

Last edited by Atomicskullz; 03-31-2023 at 17:53. Reason: No sauce
Atomicskullz is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 12:12.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode