Make a JSON/catalog representation of the resources db
961272
def resources_to_json(resources):
    
    return {
        docname: clean_resource_json(resource.__json__(resources))
        for (docname, resource)
        in resources.items()
    }
1163930
private static Map<String, Object> buildJSONBody(List<RevisionInternal> revs, final Database db) {
        // Build up a JSON body describing what revisions we want:
        final int maxRevTreeDepth = db.getMaxRevTreeDepth();
        Collection<Map<String, Object>> keys = CollectionUtils.transform(
                revs, new CollectionUtils.Functor<RevisionInternal, Map<String, Object>>() {
                    public Map<String, Object> invoke(RevisionInternal rev) {
                        AtomicBoolean haveBodies = new AtomicBoolean(false);
                        List<String> possibleAncestors = db.getPossibleAncestorRevisionIDs(
                                rev, PullerInternal.MAX_NUMBER_OF_ATTS_SINCE, haveBodies, true);
                        Map<String, Object> key = new HashMap<String, Object>();
                        key.put("id", rev.getDocID());
                        key.put("rev", rev.getRevID());
                        if (possibleAncestors != null) {
                            key.put(haveBodies.get() ? "atts_since" : "revs_from", possibleAncestors);
                        } else {
                            if (rev.getGeneration() > maxRevTreeDepth)
                                key.put("revs_limit", maxRevTreeDepth);
                        }
                        return key;
                    }
                });
        Map<String, Object> retval = new HashMap<String, Object>();
        retval.put("docs", keys);
        return retval;
    }
589868
def get_list_database(self):
        """"""
        url = "db"

        response = self.request(
            url=url,
            method='GET',
            expected_response_code=200
        )

        return response.json()
685214
def to_json(pretty=true)
      db.results_as_hash = false
      totals = db.execute("select * from totals")
      hash_total = []
      totals.each do |row|
        h = {}
        (0...row.length).each do |col|
          h[total_columns[col]] = row[col]
        end
        hash_total << h
      end
      if pretty
        JSON.pretty_generate(hash_total)
      else
        hash_total.to_json
      end
    end
517147
def json(self):
        """"""
        d = { 'id': self.id, 'format': self.formatclass.__name__,'label': self.label, 'mimetype': self.formatclass.mimetype,  'schema': self.formatclass.schema }
        if self.unique:
            d['unique'] = True
        if self.filename:
            d['filename'] = self.filename
        if self.extension:
            d['extension'] = self.extension
        if self.acceptarchive:
            d['acceptarchive'] = self.acceptarchive
        #d['parameters'] = {}

        #The actual parameters are included as XML, and transformed by clam.js using XSLT (parameter.xsl) to generate the forms
        parametersxml = ''
        for parameter in self.parameters:
            parametersxml += parameter.xml()
        d['parametersxml'] = '<?xml version="1.0" encoding="utf-8" ?><parameters>' + parametersxml + '</parameters>'
        d['converters'] = [ {'id':x.id, 'label':x.label} for x in self.converters ]
        d['inputsources'] = [ {'id':x.id, 'label':x.label} for x in self.inputsources ]

        return json.dumps(d)
790342
def save_to_json(self):
        """"""

        requestvalues = {
            'id': self.dataset,
            'publicationDate': self.publication_date.strftime('%Y-%m-%d'),
            'source': self.source,
            'refUrl': self.refernce_url,
        }        
        return json.dumps(requestvalues)
1130764
def to_json(self):
        """"""
        sets = self.sets()
        return sorted(sorted(x) for x in sets)
434460
def to_json(self):
        
        endpoints = []
        for endpoint in self.endpoints:
            list_fields = endpoint.fields
            resource_type = endpoint.Meta.resource_type
            table = endpoint.Meta.table

            data = endpoint.to_dict()
            data['fields'] = resource_type.get_type_of_fields(
                list_fields,
                table,
            )
            endpoints.append(data)

        data = {
            'title': self.title,
            'endpoints': sorted(endpoints, key=lambda x: x['name']),
        }

        return json.dumps(data)
1250845
private void loadDataIntoSourceDB() {
    String[] customers = { "{ \"name\" : \"Alice\", \"id\": 1, \"phone\" : 8793993333, \"state\":\"CA\"}",
        "{ \"name\" : \"Bob\", \"id\": 2, \"phone\" : 8793993334, \"state\":\"WA\"}",
        "{ \"name\" : \"Carl\", \"id\": 3, \"phone\" : 8793993335, \"state\":\"CA\"}",
        "{ \"name\" : \"Dennis\", \"id\": 4, \"phone\" : 8793993336, \"state\":\"OR\"}",
        "{ \"name\" : \"Evelyn\", \"id\": 5, \"phone\" : 8793993337, \"state\":\"CA\"}",
        "{ \"name\" : \"Falcon\", \"id\": 6, \"phone\" : 8793993338, \"state\":\"AZ\"}",
        "{ \"name\" : \"Gerald\", \"id\": 7, \"phone\" : 8793993339, \"state\":\"CA\"}",
        "{ \"name\" : \"Howard\", \"id\": 8, \"phone\" : 8793993340, \"state\":\"PA\"}",
        "{ \"name\" : \"Irwin\", \"id\": 9, \"phone\" : 8793993341, \"state\":\"CA\"}",
        "{ \"name\" : \"Jack\", \"id\": 10, \"phone\" : 8793993342, \"state\":\"OR\"}" };
    DocumentManager docMgr = sourceClient.newDocumentManager();
    DocumentMetadataHandle customerMetadataHandle = new DocumentMetadataHandle();
    customerMetadataHandle.getCollections().add("customers");
    docMgr.write(
        docMgr.newWriteSet().add("/moveData/customer1.json", customerMetadataHandle, new StringHandle(customers[0]).withFormat(Format.JSON))
            .add("/moveData/customer2.json", customerMetadataHandle, new StringHandle(customers[1]).withFormat(Format.JSON))
            .add("/moveData/customer3.json", customerMetadataHandle, new StringHandle(customers[2]).withFormat(Format.JSON))
            .add("/moveData/customer4.json", customerMetadataHandle, new StringHandle(customers[3]).withFormat(Format.JSON))
            .add("/moveData/customer5.json", customerMetadataHandle, new StringHandle(customers[4]).withFormat(Format.JSON))
            .add("/moveData/customer6.json", customerMetadataHandle, new StringHandle(customers[5]).withFormat(Format.JSON))
            .add("/moveData/customer7.json", customerMetadataHandle, new StringHandle(customers[6]).withFormat(Format.JSON))
            .add("/moveData/customer8.json", customerMetadataHandle, new StringHandle(customers[7]).withFormat(Format.JSON))
            .add("/moveData/customer9.json", customerMetadataHandle, new StringHandle(customers[8]).withFormat(Format.JSON))
            .add("/moveData/customer10.json", customerMetadataHandle, new StringHandle(customers[9]).withFormat(Format.JSON)));
    Random customerRandom = new Random();
    DocumentMetadataHandle orderMetadataHandle = new DocumentMetadataHandle();
    orderMetadataHandle.getCollections().add("orders");
    DocumentWriteSet orderWriteSet = docMgr.newWriteSet();
    long diff = (long) 30 * 24 * 60 * 60 * 1000;
    long endTime = new Date().getTime();
    DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
    for (int i = 0; i < 50; i++) {
      String orderDate = "\"orderdate\" : \"" + dateFormat.format(endTime - (long) (diff * Math.random())) + "\"";
      String orderDocument = "{ \"id\" : " + (i + 1) + ", \"customerid\" : " + (customerRandom.nextInt(10) + 1) + ", "
          + orderDate + "}";
      orderWriteSet.add("/moveData/order" + (i + 1) + ".json", orderMetadataHandle,
          new StringHandle(orderDocument).withFormat(Format.JSON));
    }
    docMgr.write(orderWriteSet);
    installTransform(sourceClient);
  }
576604
def to_json(self, *args, **kwargs):
        
        return json.dumps(self.to_schema(), *args, **kwargs)
18743
def load_db(file, db, verbose=True):
    
    db_data = json.load(file, verbose=verbose)
    return _load(db_data, db)
289997
def _create_json(self):
        
        data_json = {
            "rclass": "local",
            "key": self.name,
            "description": self.description,
            "packageType": self.packageType,
            "notes": "",
            "includesPattern": "**/*",
            "excludesPattern": "",
            "repoLayoutRef": self.repoLayoutRef,
            "dockerApiVersion": self.dockerApiVersion,
            "checksumPolicyType": "client-checksums",
            "handleReleases": True,
            "handleSnapshots": True,
            "maxUniqueSnapshots": 0,
            "snapshotVersionBehavior": "unique",
            "suppressPomConsistencyChecks": True,
            "blackedOut": False,
            "propertySets": [],
            "archiveBrowsingEnabled": self.archiveBrowsingEnabled,
            "yumRootDepth": 0,
        }
        return data_json
908255
def make_dict(cls, table):
        """"""
        ret_dict = {}
        for row in table:
            job_details = cls.create_from_row(row)
        ret_dict[job_details.dbkey] = job_details
        return ret_dict
1101782
def to_json(self):
        """"""
        return {
            'tpm': self.tpm,
            'cm': self.cm,
            'size': self.size,
            'node_labels': self.node_labels
        }
1314516
private void generateJSON(List<String> citationIds, ItemDataProvider provider,
			PrintWriter out) {
		StringJsonBuilderFactory factory = new StringJsonBuilderFactory();
		//create an array of citation item data objects (either for
		//the whole bibliography or for the given citation ids only)
		out.print("[");
		List<String> ids = citationIds;
		if (ids.isEmpty()) {
			ids = Arrays.asList(provider.getIds());
		}
		
		int i = 0;
		for (String id : ids) {
			if (i > 0) {
				out.print(",");
			}
			CSLItemData item = provider.retrieveItem(id);
			JsonBuilder b = factory.createJsonBuilder();
			out.print(item.toJson(b));
			++i;
		}
		
		out.println("]");
	}
1163848
def to_dict(self):
        

        data = {"model": {}}

        data["model"]["description"] = self.description
        data["model"]["entity_name"] = self.entity_name
        data["model"]["package"] = self.package
        data["model"]["resource_name"] = self.resource_name
        data["model"]["rest_name"] = self.rest_name
        data["model"]["extends"] = self.extends
        data["model"]["get"] = self.allows_get
        data["model"]["update"] = self.allows_update
        data["model"]["create"] = self.allows_create
        data["model"]["delete"] = self.allows_delete
        data["model"]["root"] = self.is_root
        data["model"]["userlabel"] = self.userlabel
        data["model"]["template"] = self.template
        data["model"]["allowed_job_commands"] = self.allowed_job_commands

        data["attributes"] = []
        for attribute in self.attributes:
            data["attributes"].append(attribute.to_dict())

        data["children"] = []
        for api in self.child_apis:
            data["children"].append(api.to_dict())

        return data
211194
def _create_json(self):
        
        data_json = {
            "name": self.name,
            "description": self.description,
            "autoJoin": self.autoJoin,
            "realm": self.realm,
        }
        return data_json