refactor json serializer
add unit test