Add protocol attribute, clean up json code