Fix JSON generation for if statements