'Serialize fields to JSON.'

def fields_to_partial_json(self):

    jobj = {}
    omitted = set()
    for (slot, field) in six.iteritems(self._fields):
        value = getattr(self, slot)
        if field.omit(value):
            omitted.add((slot, value))
        else:
            try:
                jobj[field.json_name] = field.encode(value)
            except errors.SerializationError as error:
                raise errors.SerializationError('Could    not    encode    {0}    ({1}):    {2}'.format(slot, value, error))
    return jobj
