stdser
Implements FunL data serialization to format that can be stored or transmitted over network and also deserialization back to FunL data. JSON encoding/decoding does the same but it has limitations with maps converted to JSON objects as JSON objects require keys being strings.
Also opaque:bytearray is encoded as base64 encoded string.
Following types can be encode/decoded with stdser:
- int
- float
- bool
- string
- list (containing items of these types)
- map (values being one of these types)
- opaque:bytearray
Encoding and decoding utilize JSON encoding and decoding at bottom. On top of JSON stdser converts data to/from to pairs of data (pairs being lists of two items):
- First item : type tag (string) ('int', 'float', 'bool', 'string', 'list', 'map', 'bytearray')
- Second item : value (which in list/map case contain more these pairs)
List value is presented list of pairs. Map value is presented as list of pairs:
- Key pair (2 item list)
- tag (string)
- value
- Value pair (2 item list)
- tag (string)
- value
Encodes FunL values to bytearray (JSON underneath).
type: function
Format:
call(stdser.encode <value>) -> <list: is-ok error-description data-bytearray>
Return value: list
Returned list contains
- bool: true if encode succeeded, false otherwise
- error description (string), '' if succeeded
- target data as bytearray (stdbytes opaque type)
Decodes bytearray data (JSON) to FunL value.
type: function
Format:
call(stdser.decode <data-bytearray>) -> <list: is-ok error-description value>
Return value: list
Returned list contains
- bool: true if encode succeeded, false otherwise
- error description (string), '' if succeeded
- decoded FunL value