Photon Quantum 3.0.0

Public Member Functions | Protected Member Functions | List of all members
QuantumJsonSerializer Class Reference

A serializer that is able to deserialize JSON produced by QuantumUnityJsonSerializer. Handles SerializeReference, Unity-style byte[] serialization and fixed-size buffers. Uses UnityJsonUtilityConvert under the hood. More...

Inherits IAssetSerializer.

Public Member Functions

AssetObject[] DeserializeAssets (Stream stream)
 Deserializes the assets from a stream. More...
 
IRuntimeConfig DeserializeConfig (Stream stream)
 Deserializes the runtime configuration from a stream. More...
 
IRuntimePlayer DeserializePlayer (Stream stream)
 Deserializes the runtime player from a stream. More...
 
IGameResult DeserializeResult (Stream stream)
 Deserializes the game result from a stream. More...
 
object FromJson (string json, Type type)
 Converts a JSON string to an object. More...
 
FromJson< T > (JObject json)
 Converts a JSON object to an object. More...
 
FromJson< T > (string json)
 Converts a JSON string to an object. More...
 
string PrintObject (object obj)
 Prints the object as a JSON string. More...
 
void SerializeAssets (Stream stream, AssetObject[] assets)
 Serializes the assets to a stream. More...
 
void SerializeConfig (Stream stream, IRuntimeConfig config)
 Serializes the runtime configuration to a stream. More...
 
void SerializePlayer (Stream stream, IRuntimePlayer player)
 Serializes the runtime player to a stream. More...
 
void SerializeResult (Stream stream, IGameResult result)
 Serializes the game result to a stream. More...
 
string ToJson< T > (T obj)
 Converts an object to a JSON string. More...
 

Protected Member Functions

virtual TextReader CreateReader (Stream stream)
 Creates a text reader for the given stream. More...
 
virtual TextWriter CreateWriter (Stream stream)
 Creates a text writer for the given stream. More...
 

Detailed Description

A serializer that is able to deserialize JSON produced by QuantumUnityJsonSerializer. Handles SerializeReference, Unity-style byte[] serialization and fixed-size buffers. Uses UnityJsonUtilityConvert under the hood.

Member Function Documentation

◆ FromJson< T >() [1/2]

T QuantumJsonSerializer.FromJson< T > ( string  json)
inline

Converts a JSON string to an object.

Template Parameters
TThe type of the object to convert to.
Parameters
jsonThe JSON string to convert.
Returns
The converted object.

◆ FromJson()

object QuantumJsonSerializer.FromJson ( string  json,
Type  type 
)
inline

Converts a JSON string to an object.

Parameters
jsonThe JSON string to convert.
typeThe type of the object to convert to.
Returns
The converted object.

◆ FromJson< T >() [2/2]

T QuantumJsonSerializer.FromJson< T > ( JObject  json)
inline

Converts a JSON object to an object.

Template Parameters
TThe type of the object to convert to.
Parameters
jsonThe JSON object to convert.
Returns
The converted object.

◆ ToJson< T >()

string QuantumJsonSerializer.ToJson< T > ( obj)
inline

Converts an object to a JSON string.

Template Parameters
TThe type of the object to convert.
Parameters
objThe object to convert.
Returns
The JSON string representation of the object.

◆ SerializeConfig()

void QuantumJsonSerializer.SerializeConfig ( Stream  stream,
IRuntimeConfig  config 
)
inline

Serializes the runtime configuration to a stream.

Parameters
streamThe stream to serialize to.
configThe runtime configuration to serialize.

◆ SerializePlayer()

void QuantumJsonSerializer.SerializePlayer ( Stream  stream,
IRuntimePlayer  player 
)
inline

Serializes the runtime player to a stream.

Parameters
streamThe stream to serialize to.
playerThe runtime player to serialize.

◆ SerializeAssets()

void QuantumJsonSerializer.SerializeAssets ( Stream  stream,
AssetObject[]  assets 
)
inline

Serializes the assets to a stream.

Parameters
streamThe stream to serialize to.
assetsThe assets to serialize.

◆ DeserializeConfig()

IRuntimeConfig QuantumJsonSerializer.DeserializeConfig ( Stream  stream)
inline

Deserializes the runtime configuration from a stream.

Parameters
streamThe stream to deserialize from.
Returns
The deserialized runtime configuration.

◆ DeserializePlayer()

IRuntimePlayer QuantumJsonSerializer.DeserializePlayer ( Stream  stream)
inline

Deserializes the runtime player from a stream.

Parameters
streamThe stream to deserialize from.
Returns
The deserialized runtime player.

◆ SerializeResult()

void QuantumJsonSerializer.SerializeResult ( Stream  stream,
IGameResult  result 
)
inline

Serializes the game result to a stream.

Parameters
streamThe stream to serialize to.
resultThe game result to serialize.

◆ DeserializeResult()

IGameResult QuantumJsonSerializer.DeserializeResult ( Stream  stream)
inline

Deserializes the game result from a stream.

Parameters
streamThe stream to deserialize from.
Returns
The deserialized game result.

◆ DeserializeAssets()

AssetObject [] QuantumJsonSerializer.DeserializeAssets ( Stream  stream)
inline

Deserializes the assets from a stream.

Parameters
streamThe stream to deserialize from.
Returns
The deserialized assets.

◆ PrintObject()

string QuantumJsonSerializer.PrintObject ( object  obj)
inline

Prints the object as a JSON string.

Parameters
objThe object to print.
Returns
The JSON string representation of the object.

◆ CreateReader()

virtual TextReader QuantumJsonSerializer.CreateReader ( Stream  stream)
protectedvirtual

Creates a text reader for the given stream.

Parameters
streamThe stream to create the reader for.
Returns
The created text reader.

◆ CreateWriter()

virtual TextWriter QuantumJsonSerializer.CreateWriter ( Stream  stream)
protectedvirtual

Creates a text writer for the given stream.

Parameters
streamThe stream to create the writer for.
Returns
The created text writer.