moved json generation to the class