validation and creating json