Script that flattens JSON