Json generation;delete empty messages that are not found in templates