Quirrel4.41.0

iostream.blob.writeobject

Method of blob, from module "iostream"
instance.writeobject(obj, [classes: table|null])

Serializes the object to the stream

Parameters

objanythe value to serialize
classestable|nullclasses the serialized data is allowed to instantiate optional

Notes

See iostream.stream.writeobject for the generic contract. Writing past the current len grows this blob to fit, the same as writen.

Example

examples/iostream/blob/writeobject.nut
from "iostream" import blob

let b = blob(0)               // empty: serializing grows it
b.writeobject([1, 2, 3])
println("b.len() > 0 =", b.len() > 0)

b.seek(0)
let back = b.readobject()
println("back.len(), back[0], back[1], back[2] =", $"{back.len()}:{back[0]},{back[1]},{back[2]}")
Output:
b.len() > 0 = true
back.len(), back[0], back[1], back[2] = 3:1,2,3

See also

writeobjectSerializes the object to the stream
readobjectDeserializes an object from the stream
blobclass index