Added the function of encode for json, and the xml features.