The canonical view developed in T259932 is good for storing and for a reasonably compact view of ZObjects for human consumption. For machines to process it, it is more convenient to have it in a more uniform presentation.
The normalized representation of a ZObject is a tree where all leaves are ZObjects of the type Z6/String or Z9/Reference. No other types appear on the leaves, but the inner nodes could be of any type.
This also means, no escaping of strings will be needed as all strings are explicitly typed.
All Z10/Lists are represented by ZObjects of type Z10/List and not by arrays in the JSON representation. All objects of type Z10/List have either both the Z10K1 and Z10K2 key, or neither (i.e. it is an empty list).
So the following steps need to be done by the normalizer:
- trim keys
- sort keys
- ensure that all strings are represented as explicit ZObjects of type Z6/String
- ensure that all references are represented as explicit ZObjects of type Z9/Reference
- ensure that lists represented by ZObjects of type Z10/List
- ensure that all ZObjects of type Z10/List either have both keys or none
- ensure that all ZObjects are trees with all leaves being either of type Z6/String or Z9/Reference (that should be a given if all previous steps are fulfilled)
Normalization must be performed on any input to any evaluation. It will considerably simplify writing function implementations.