rewrite api to support json data