Anvil
Anvil.API.Json Class Reference

Represents a json engine structure. More...

+ Inheritance diagram for Anvil.API.Json:
+ Collaboration diagram for Anvil.API.Json:

Public Member Functions

string Dump ()
 Dumps the content of the json object to a string. More...
 
NwObjectToNwObject (Location location, NwGameObject? owner=null, bool loadObjectState=true)
 Attempts to parse this json structure into a NwObject. More...
 
T? ToNwObject< T > (Location location, NwGameObject? owner=null, bool loadObjectState=true)
 Attempts to parse this json structure into a NwObject. More...
 
- Public Member Functions inherited from Anvil.API.EngineStructure
void Dispose ()
 

Static Public Member Functions

static implicit operator Json (IntPtr intPtr)
 
static Json Parse (string jsonString)
 Parses the specified string as a json structure. More...
 
- Static Public Member Functions inherited from Anvil.API.EngineStructure
static implicit operator IntPtr (EngineStructure engineStructure)
 

Properties

override int StructureId [get]
 
- Properties inherited from Anvil.API.EngineStructure
bool IsValid [get]
 Gets if this object is valid. More...
 
abstract int StructureId [get]
 

Additional Inherited Members

- Protected Member Functions inherited from Anvil.API.EngineStructure
 EngineStructure (IntPtr handle, bool memoryOwn)
 

Detailed Description

Represents a json engine structure.

This class is specifically for compatibility with the base game.
It is recommended to use JsonUtility and System.Text.Json for all json-related problems in C#.

Member Function Documentation

◆ Dump()

string Anvil.API.Json.Dump ( )
inline

Dumps the content of the json object to a string.

Returns

◆ Parse()

static Json Anvil.API.Json.Parse ( string  jsonString)
inlinestatic

Parses the specified string as a json structure.

Parameters
jsonStringThe json string to parse.
Returns
The parsed json structure.

◆ ToNwObject()

NwObject? Anvil.API.Json.ToNwObject ( Location  location,
NwGameObject owner = null,
bool  loadObjectState = true 
)
inline

Attempts to parse this json structure into a NwObject.

Parameters
locationThe location to spawn the parsed object.
ownerIf this object is an item, the owner of the parsed item.
loadObjectStateIf the object should load object state info from the json structure.
Returns
The created object, or null if parsing failed.

◆ ToNwObject< T >()

T? Anvil.API.Json.ToNwObject< T > ( Location  location,
NwGameObject owner = null,
bool  loadObjectState = true 
)
inline

Attempts to parse this json structure into a NwObject.

Parameters
locationThe location to spawn the parsed object.
ownerIf this object is an item, the owner of the parsed item.
loadObjectStateIf the object should load object state info from the json structure.
Returns
The created object, or null if parsing failed.
Type Constraints
T :NwObject 

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