FOA - Fast Object and Array encoding/decoding
The intention of the FOA specification is to support efficient encoding/decoding of data (array, objects and files) for transfering between systems. It's stream based and provides methods for inline binary data in the character stream.
This section briefly describes the FOA encoding. Each encoded line contains either data (could be an array entry or an object member) or an special char. Each special char or data item must be followed by a newline (\n) character.
The special chars are:
'(': begin object
'[': begin array
']': end array
')': end object
Each data, array or object (type) can also be named by
'name = type'.
Arrays and objects can be unlimited nested in each other.
item := (name '=' data | data) + '\n' data := text | spec name := text - '=' text := any char spec := ()
Viewed from another angle: all encoded rows follows the pattern
'[name = ] data\n' (*), where the name is optional (the data is
anonymous) and data is either one of '()' or another expression like (*).
This is an example of how an array (named arr) containing two structures (persons with named members) will be encoded:
arr = [ ( name = Albert Einstein born = March 14, 1879 ) ( name = Isaac Newton born = December 25, 1642 ) ]
See the encoding page for more examples.
If escaping is turned on (the default), then all special chars will be escaped when encoding and unescaped when decoding (they are replaced by HTTP encoded equivalents). This is all transparent to the library user.
The escaping can be turned off thru foa_set_mode() to improve performance.