<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, path, points=50, meta=None):
 """ Write the results of the fit to a json file at `path`. `points` will define the length of the `fit` array. If `meta` is given, a `meta` key be added with the given value. The json object has the form #!text { 'meta': meta } """

        pointspace = self.pointspace(num=points)
        fit_points = numpy.dstack(pointspace['fit'])[0]
        data_points = numpy.dstack(pointspace['data'])[0]

        fit = [ [ point[0],  point[1] ] for point in fit_points ]
        data = [ [ point[0],  point[1] ] for point in data_points ]

        obj = {'data': data, 'fit': fit}
        if meta: obj['meta'] = meta

        f = open(path, 'w')
        json.dump(obj, f)
        f.close