implementing toJSONAsync