[enh] Implement an extended JSON encoder and support sets