How to parse if, else if, else block to JSON format