5 ms·
This is just an implementation of a binary encoded Property Tree. And not the best implementation out there since it lacks the redundant key/value elimination
by gilgoomesh 14y ago
This is just an implementation of a binary encoded Property Tree.
And not the best implementation out there since it lacks the redundant key/value elimination that more compact serialization formats use. Consider an array of maps where each of the maps have the same keys. By eliminating the redundant keys (have each subsequent occurrence simply reference earlier occurrences) you can halve the encoded data size relative to implementations without redundant elimination.
It also lacks a canonical string encoding. All strings are saved as raw binary data making it terrible for data interchange between environments with different string encodings.
C/C++/Objective-C users have many better options than this. In Mac/iOS/Cocoa/CoreFoundation, you can use Apple's Binary PList which is open sourced here:
http://www.opensource.apple.com/source/CF/CF-476.10/CFBinaryPList.c
In non-Apple C/C++ environments, you can use the open source implementation of Apple's PList here:
https://github.com/JonathanBeck/libplist
- tarabukka 14y agoAlthough if you're running this over HTTP, you might end up compressing it with DEFLATE (either directly or with gzip), which partly involves adding references to duplicated data... I'm not sure what the use case for this format is meant to be, though, so that might not apply.
- johnbellone 14y agoBoost has a decent implementation of just a property tree which given a little magic can pretty much serialize into any key-value format. I used it pretty successfully for commandline and INI values for a simple game engine.
- andrewvc 14y agoAs far as redundant kv encoding isn't gzip good enough? Sure, it's more generalized, but tailored compression schemes often aren't the win they're touted as. Additionally, they can't exploit scenarios where multiple pairs are repeated (for instance gzip would compress [{x: 1}, {x: 1}, {x: 1}, ...] far more efficiently.
- gilgoomesh 14y agoActually, Apple's implementation does handle multiple pair redundancy since all CFArrays and CFDictionarys added to the PList are uniqued. Obviously, further GZIPing the result will always make it more compact but GZIP on uniqued result is likely to result in a more compact representation than GZIP on the non-uniqued result.