Moving json generation to server side