<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:

def to_json(self, *, include=None):
        ''' Serializes this model to a JSON representation so it can be sent
        via an HTTP REST API '''
        json = dict()

        if include is None or 'id' in include or '*' in include:
            json['id'] = self.id

        if include is None or '_type' in include or '*' in include:
            json['_type'] = type(self).cls_key()

        def fieldfilter(fieldtuple):
            return \
                not fieldtuple[1].private and \
                not isinstance(fieldtuple[1], Relation) and (
                    include is None or fieldtuple[0] in include or '*' in include
                )

        json.update(dict(starmap(
            lambda fn, f: (fn, f.to_json(getattr(self, fn))),
            filter(
                fieldfilter,
                self.proxy
            )
        )))

        for requested_relation in parse_embed(include):
            relation_name, subfields = requested_relation

            if not hasattr(self.proxy, relation_name):
                continue

            relation = getattr(self.proxy, relation_name)

            if isinstance(relation, ForeignIdRelation):
                item = relation.get()

                if item is not None:
                    json[relation_name] = item.to_json(include=subfields)
                else:
                    json[relation_name] = None
            elif isinstance(relation, MultipleRelation):
                json[relation_name] = list(map(lambda o: o.to_json(include=subfields), relation.get()))

        return json