Dayz Build 1.29.163047, Scripts Rev. 123548
Dayz Code Explorer by Zeroy
Loading...
Searching...
No Matches
JsonSerializer Class Reference

Class for sending RPC over network. More...

Inheritance diagram for JsonSerializer:
Serializer

Private Member Functions

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

Detailed Description

Class for sending RPC over network.

// example sending
void Send()
{
ScriptRPC rpc = new ScriptRPC();
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;
array<float> farray;
ctx.Read(num);
ctx.Read(text);
ctx.Read(farray);
}
map m_Player
void OnRPC(ParamsReadContext ctx)
proto native void Send(Object target, int rpc_type, bool guaranteed, PlayerIdentity recipient=NULL)
Initiate remote procedure call.
proto bool Write(void value_out)
proto bool Read(void value_in)
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
ERPCs
Definition erpcs.c:2
Serializer ParamsReadContext
Definition gameplay.c:15

Definition at line 49 of file gameplay.c.

Constructor & Destructor Documentation

◆ JsonSerializer()

void JsonSerializer ( )
inlineprivate

Definition at line 51 of file gameplay.c.

◆ ~JsonSerializer()

void ~JsonSerializer ( )
inlineprivate

Definition at line 52 of file gameplay.c.

Member Function Documentation

◆ ReadFromString()

proto bool 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

Referenced by GetControlMappingInfo(), and UIScriptedMenu::GetControlMappingInfo().

◆ WriteToString()

proto bool 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
Data data;
string textOut;
bool nice = false;
bool ok = js.WriteToString(data, false, textOut);
void JsonSerializer()
Definition gameplay.c:51
proto bool WriteToString(void variable_out, bool nice, out string result)
Script variable serialization to json string.

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