Stream interview question

State machine based on JSON input and expected output