When coding, this codec maintains a map of the keys that have been seen the beginning of the coding operation. Each key is assigned an unique numerical index starting at 1. If the key as not been seen before, encode the negative value of the index and the value of the key. If the key has been before, encode the positive value of the key's index.
Similarly, when decoding, the codec maintains an array that maps key index to the value of the key. When decoding, if the encoded index is negative, then it is followed by the value of the key to associate with the positive value of the encoded index. If the encoded index is positive, then the encoded index is used to lookup the value of the key.
The encoded index is 0, then there are no more keys in the JSON object. @author slim
|
|
|
|
|
|