Class JsonStructuredRecordArraySerializer
Human-readable, pretty-printed JSON serializer for an array of StructuredRecord.
Implements
Inherited Members
Namespace: Serenity.StructuredPersistence.Infrastructure.KeyValue
Assembly: Serenity.StructuredPersistence.KeyValue.dll
Syntax
public class JsonStructuredRecordArraySerializer : ISerializer<StructuredRecord[]>
Remarks
Used by the LocalFile leaderboard backend so board files can be opened, inspected, and edited by hand instead of requiring a hex viewer, unlike StructuredRecordArraySerializer's binary format.
Payload shape: an indented JSON array of {"id":..., "fields":{...}} objects. Every field
is written as an explicit {"kind":..., "value":...} pair rather than a bare JSON scalar,
mirroring how Serenity.StructuredPersistence.Infrastructure.Http.Json.StructuredWireJson
encodes the same StructuredValue shape for the Http backend's wire protocol. This
is required, not merely for symmetry: a bare JSON number cannot tell a
Long apart from a Double on
read-back, and JsonValue parses every JSON number into a double —
which only exactly represents integers up to 2^53. Long values
are therefore additionally quoted as digit strings (same reasoning as
WriteQuotedLong(string, long)), so a 64-bit score round-trips exactly instead of
silently losing precision.
Constructors
JsonStructuredRecordArraySerializer()
Declaration
public JsonStructuredRecordArraySerializer()
Methods
Deserialize(ReadOnlySpan<byte>)
Declaration
public StructuredRecord[] Deserialize(ReadOnlySpan<byte> bytes)
Parameters
| Type | Name | Description |
|---|---|---|
| ReadOnlySpan<byte> | bytes |
Returns
| Type | Description |
|---|---|
| StructuredRecord[] |
Exceptions
| Type | Condition |
|---|---|
| JsonParseException | Thrown when the payload is not valid JSON, or does not match the expected record-array shape. |
Serialize(StructuredRecord[])
Declaration
public byte[] Serialize(StructuredRecord[] value)
Parameters
| Type | Name | Description |
|---|---|---|
| StructuredRecord[] | value |
Returns
| Type | Description |
|---|---|
| byte[] |