Serialize( ) method (JsonSerializer)

Serializes an ABL class-based object to the specified JSON stream.

Return type: VOID

Access: PUBLIC

Applies to: Progress.IO.JsonSerializer class

Syntax

Serialize( INPUT object-reference AS Progress.Lang.Object,
           INPUT output-stream AS Progress.IO.OutputStream )
object-reference
The class-based object to be serialized.
output-stream
The stream to which the object-reference is serialized.

The following code sample serializes and deserializes myObj:

DEFINE VARIABLE myFileOutStream AS Progress.IO.FileOutputStream.
DEFINE VARIABLE myFileInStream  AS Progress.IO.FileInputStream.
DEFINE VARIABLE mySerializer    AS Progress.IO.JsonSerializer.
DEFINE VARIABLE myObj           AS Acme.MyClass.

myObj = NEW  Acme.MyClass().

mySerializer = NEW Progress.IO.JsonSerializer(FALSE).

/* Serialize object */
myFileOutStream = NEW Progress.IO.FileOutputStream("MyClass.json").
mySerializer:Serialize(myObj, myFileOutStream).
myFileOutStream:Close().

/* Deserialize object */
myFileInStream = NEW Progress.IO.FileInputStream("MyClass.json").
myObj = CAST(mySerializer:Deserialize(myFileInStream), Acme.MyClass).
myFileInStream:Close().

Notes