Exports a model to a JSON file.
8845
static void exportModel() throws Exception {
    HttpClient client = new HttpClient();
    GetMethod get = new GetMethod(URL + "/2/ExportModel.json?model=MyInitialNeuralNet");
    int status = client.executeMethod(get);
    if( status != 200 )
      throw new Exception(get.getStatusText());
    JsonObject response = (JsonObject) new JsonParser().parse(new InputStreamReader(get.getResponseBodyAsStream()));
    JsonElement model = response.get("model");
    JsonWriter writer = new JsonWriter(new FileWriter(JSON_FILE));
    writer.setLenient(true);
    writer.setIndent("  ");
    Streams.write(model, writer);
    writer.close();
    get.releaseConnection();
  }
481298
def json_to_model(self, model_name, j):
        """"""
        if model_name not in self.swagger_dict['definitions']:
            raise ValidationError("Swagger spec has no definition for model %s" % model_name)
        model_def = self.swagger_dict['definitions'][model_name]
        log.debug("Unmarshalling json into %s" % model_name)
        return unmarshal_model(self.spec, model_def, j)
1213145
def to_json_file(file, data, pretty):
    
    json_string = to_json(data, pretty)
    file_utils.write_to_file(file, json_string)
1116748
def from_json(self, json, models=None):
        ''' 
        '''
        if json is None:
            return None
        elif not isinstance(json, dict):
            raise DeserializationError("%s expected a dict or None, got %s" % (self, json))
        new_data = {}
        for key, value in json.items():
            key = self.keys_type.from_json(key, models)
            if isinstance(value, dict) and '__ndarray__' in value:
                new_data[key] = decode_base64_dict(value)
            elif isinstance(value, list) and any(isinstance(el, dict) and '__ndarray__' in el for el in value):
                new_list = []
                for el in value:
                    if isinstance(el, dict) and '__ndarray__' in el:
                        el = decode_base64_dict(el)
                    elif isinstance(el, list):
                        el = self.values_type.from_json(el)
                    new_list.append(el)
                new_data[key] = new_list
            else:
                new_data[key] = self.values_type.from_json(value, models)
        return new_data
1125143
def to_json(self, *, include=None):
        '''  '''
        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
616039
def serialize(value, field):
    
    assert isinstance(field, forms.Field)
    if isinstance(field, forms.ModelMultipleChoiceField):
        return json.dumps([v.pk for v in value])
    # todo: remove
    if isinstance(value, models.Model):
        return value.pk
    return value
945212
def to_json_file(self, json_file_path):
        
        with open(json_file_path, "w", encoding='utf-8') as writer:
            writer.write(self.to_json_string())
242531
def to_yaml_file(obj, f):
    
    yaml.dump(rapidjson.loads(to_json(obj)), f)
104747
def export_to_file(request):
    
    if request.method == 'POST':
        form = ExportForm(request.POST)
        if form.is_valid():
            payload = export_pages(form.cleaned_data['root_page'], export_unpublished=True)
            response = JsonResponse(payload)
            response['Content-Disposition'] = 'attachment; filename="export.json"'
            return response
    else:
        form = ExportForm()

    return render(request, 'wagtailimportexport/export_to_file.html', {
        'form': form,
    })
758509
def to_json(obj):
    """"""
    i = StringIO.StringIO()
    w = Writer(i, encoding='UTF-8')
    w.write_value(obj)
    return i.getvalue()
1170580
def model_to_file(model, filename):
    
    with open(filename, 'wb') as f:
        pickle.dump(model, f)
738968
def to_json_file(self, path, file_name=None):
        """"""
        if bool(path) and os.path.isdir(path):
            self.write_to_json(path, file_name)
        else:
            self.write_to_json(os.getcwd(), file_name)
1253527
def dump(obj, fp, **kwargs):
    """"""
    kwargs['default'] = serialize
    return json.dump(obj, fp, **kwargs)
1225950
public static void writeJsonMeta(JavaFileObject fileObject, JsonModelModel model)
			throws IOException {
		MvelTemplate.writeJsonMeta(fileObject, model);
	}
230191
def save_to_json(self):
        """"""
        requestvalues = {
            'Dataset': self.dataset,
            'Header' : self._get_item_array(self.header),
            'Filter' : self._get_item_array(self.filter),
            'Stub' : self._get_item_array(self.stub),
            'Frequencies': self.frequencies
        }
        return json.dumps(requestvalues)
870796
def export(self):
        """"""
        fields = ['id', 'host', 'port', 'user']
        out = {}
        for field in fields:
            out[field] = getattr(self, field, None)
        out['mountOptions'] = self.mount_opts
        out['mountPoint'] = self.mount_point
        out['beforeMount'] = self.cmd_before_mount
        out['authType'] = self.auth_method
        out['sshKey'] = self.ssh_key
        return json.dumps(out, indent=4)
1161867
def dump_json(model, batch_len=200000, use_natural_keys=True, verbosity=1):
    
    model = get_model(model)

    N = model.objects.count()

    if verbosity > 0:
        widgets = [pb.Counter(), '/%d rows: ' % (N,), pb.Percentage(), ' ', pb.RotatingMarker(), ' ', pb.Bar(),' ', pb.ETA()]
        i, pbar = 0, pb.ProgressBar(widgets=widgets, maxval=N).start()

    JSONSerializer = serializers.get_serializer("json")
    jser = JSONSerializer()

    if verbosity > 0:
        pbar.update(0)
    for i, partial_qs in enumerate(util.generate_slices(model.objects.all(), batch_len=batch_len)):
        with open(model._meta.app_label.lower() + '--' + model._meta.object_name.lower() + '--%04d.json' % i, 'w') as fpout:
            if verbosity > 0:
                pbar.update(i*batch_len)
            jser.serialize(partial_qs, indent=1, stream=fpout, use_natural_keys=use_natural_keys)
    if verbosity > 0:
        pbar.finish()