Added new method to convert element classes into JsonObject.