add JSON output to mapper
initial implementation of reducer function