Updated code to use JSON serializer