DayZ 1.24
Loading...
Searching...
No Matches
JsonSerializer Class Reference

Class for sending RPC over network. More...

Inheritance diagram for JsonSerializer:
[legend]
Collaboration diagram for JsonSerializer:
[legend]

Private Member Functions

void JsonSerializer ()
 
void ~JsonSerializer ()
 
proto bool WriteToString (void variable_out, bool nice, out string result)
 Script variable serialization to json string.
 
proto bool ReadFromString (void variable_in, string jsonString, out string error)
 Json string deserialization to script variable.
 
- Private Member Functions inherited from Serializer
void Serializer ()
 
void ~Serializer ()
 

Detailed Description

Class for sending RPC over network.

// example sending
void Send()
{
rpc.Write(645);
rpc.Write("hello");
array<float> farray = {1.2, 5.6, 8.1};
rpc.Write(farray);
rpc.Send(m_Player, ERPCs.RPC_TEST, true, m_Player.GetIdentity());
}
// example receive
{
int num;
string text;
ctx.Read(num);
ctx.Read(text);
ctx.Read(farray);
}
ERPCs
Definition ERPCs.c:2
void OnRPC(ParamsReadContext ctx)
PlayerBase m_Player
Serialization general interface. Serializer API works with:
Definition Serializer.c:56

Definition at line 49 of file gameplay.c.

Constructor & Destructor Documentation

◆ JsonSerializer()

void JsonSerializer::JsonSerializer ( )
inlineprivate

Definition at line 51 of file gameplay.c.

51{}

◆ ~JsonSerializer()

void JsonSerializer::~JsonSerializer ( )
inlineprivate

Definition at line 52 of file gameplay.c.

52{}

Member Function Documentation

◆ ReadFromString()

proto bool JsonSerializer::ReadFromString ( void variable_in,
string jsonString,
out string error )
private

Json string deserialization to script variable.

Parameters
variable_inscript variable to be deserialized from string
jsonStringthe input string
errorfrom the deserialization. Is used only if the return value of the function is false
Returns
if the deserialization was successful
// Example json
// {
// "i": 6, // Int
// "f": 3.5, // Float
// "v": [1.1,2.2,3.3] // Vector3 is static array of size 3
// "s": "string", // String
// "subData": { // Object
// "staticIArr": [9,8], // Static array (of ints)
// "dynamicSArr": ["string1","string2"] // Dynamic array (of strings)
// }, //
// "fSet": [12.3,14.7], // Set (of floats)
// "ifMap": { // Map (of int, float), only valid key type is int, enum, string
// "3": 4.5, // Map key has to be as string
// "4": 5.5
// }
// }
Data data = new Data;
string input = // valid json string;
string error;
bool ok = js.ReadFromString(data, input, error);
JsonDataAreaData Data

◆ WriteToString()

proto bool JsonSerializer::WriteToString ( void variable_out,
bool nice,
out string result )
private

Script variable serialization to json string.

Parameters
variable_outscript variable to be serialized to string
niceif the string should be formated for human readability
resultfrom the serialization, output or error depending on the return value
Returns
if the serialization was successful
string textOut;
bool nice = false;
bool ok = js.WriteToString(data, false, textOut);
Class for sending RPC over network.
Definition gameplay.c:50
void JsonSerializer()
Definition gameplay.c:51

The documentation for this class was generated from the following file: