add encoding customization to json serializer and corresponding test case