Scripting API
Scripting API
SceneJson
Class in Abyss.Core.Scenes, from Abyss.Core.
Reads and writes a SceneDocument as JSON.
public static class SceneJsonRemarks
Written by hand against Utf8JsonWriter and JsonDocument rather than through a serializer, for two reasons that pull the same way. The reflection-based path does not survive NativeAOT, which this repository publishes to and measures; and a scene file is a compatibility surface that will outlive several versions of the types in it, so the mapping between the file and the model is better as code somebody can read than as a consequence of how the model's properties happen to be named this week.
Nothing here is a dependency: System.Text.Json is in the framework.
Methods
Write
public static void Write(SceneDocument document, Stream into)Writes the document to a stream as UTF-8 JSON.
Parameters
document: What to write.into: Where to write it. Left open.
ToJson
public static string ToJson(SceneDocument document)Writes the document to a string, which is what a test wants.
Parameters
document: What to write.
Read
public static SceneDocument Read(Stream from)Reads a document from a stream of UTF-8 JSON.
Parameters
from: Where to read it from.
Exceptions
SceneFormatException: The stream is not a scene this build reads.
Parse
public static SceneDocument Parse(string json)Reads a document from a string of JSON.
Parameters
json: The document's text.
Exceptions
SceneFormatException: The text is not a scene this build reads.
