handing json request and response properly