Obtain a list of keys (JSON files) stored in datapath
427520
public function getSets()
    {
        $setlist = [];
        foreach (glob($this->datapath."/data/*.json") as $file) {
            preg_match("`".$this->datapath."/data/(.*).json`", $file, $key, PREG_OFFSET_CAPTURE);
            $setlist[] = $key[1][0];
        }
        return $setlist;
    }
1239849
def get_keys_from_shelve(file_name, file_location):
    
    temp_list = list()
    file = __os.path.join(file_location, file_name)
    shelve_store = __shelve.open(file)
    for key in shelve_store:
        temp_list.append(key)
    shelve_store.close()
    return temp_list
917019
def _toDict(datastorage_obj,recursive=True):
    
    if "items" not in dir(datastorage_obj): return datastorage_obj
    d = dict()
    for k, v in datastorage_obj.items():
        try:
            d[k] = _toDict(v)
        except Exception as e:
            log.info("In toDict, could not convert key %s to dict, error was %s" %
                     (k, e))
            d[k] = v
    return d
881835
def __ReadFromFile(self, datapath):
        
        def _create_meta(_datapath):
            """Just simply returns some dict. This functions exists in order to keep DRY"""
            meta = {
                'series_number': 0,
                'datadir': _datapath
            }
            return meta

        path, ext = os.path.splitext(datapath)
        ext = ext[1:]
        if ext in ('pklz', 'pkl'):
            logger.debug('pklz format detected')
            from . import misc
            data = misc.obj_from_file(datapath, filetype='pkl')
            data3d = data.pop('data3d')
            # metadata must have series_number
            metadata = _create_meta(datapath)
            metadata.update(data)

        elif ext in ['hdf5']:
            from . import hdf5_io
            datap = hdf5_io.load_dict_from_hdf5(datapath)
            # datap = self.read_hdf5(datapath)
            data3d = datap.pop('data3d')

            # back compatibility
            if 'metadata' in datap.keys():
                datap = datap['metadata']
            # metadata must have series_number
            metadata = _create_meta(datapath)
            metadata.update(datap)

        elif ext in ['idx']:
            from . import idxformat
            idxreader = idxformat.IDXReader()
            data3d, metadata = idxreader.read(datapath)
        elif ext in ['dcm', 'DCM', 'dicom']:
            data3d, metadata = self._read_with_sitk(datapath)
            metadata = self._fix_sitk_bug(datapath, metadata)
        elif ext in ["bz2"]:
            new_datapath = tgz.untar(datapath)
            data3d, metadata = self.__ReadFromDirectory(new_datapath)
        else:
            logger.debug('file format "' + str(ext) + '"')
            # reading raw file
            data3d, metadata = self._read_with_sitk(datapath)
        return data3d, metadata
355921
def retrieve_data(file_paths):

    
    data_dict = {}
    for file_path in file_paths:
        with open(file_path) as fh:
            try:
                content = yaml.load(fh.read())
            except yaml.YAMLError as e:
                raise MiuraException(
                    "Unable to parse yaml at {0}: \n {1}".format(
                        file_path,
                        str(e)
                    ))
            if not isinstance(content, dict):
                raise MiuraException(
                    "{0} is does not translate to a dictionary!".format(file_path)
                )
            data_dict.update(content)
    return data_dict
744929
function Json(filepath) {
  this.filepath = filepath;
  this.dirname = undefined;
  this.json = undefined;
  this.realpath = undefined;
}
476123
function readData(datapath, layer, callback) {
  var features = [];

  var options = {
    delimiter: ',',
    columns: true
  };

  fs.createReadStream(path.join(datapath, 'meta', `wof-${layer}-latest.csv`))
    .pipe(parse(options))
    .pipe(loadJSON.create(datapath))
    .pipe(isActiveRecord.create())
    .pipe(filterOutNamelessRecords.create())
    .pipe(filterOutUnimportantRecords.create())
    .pipe(extractFields.create())
    .pipe(simplifyGeometry.create())
    .pipe(sink.obj(function(feature) {
      features.push(feature);
    }))
    .on('finish', function() {
      callback(features);
    });

}
587589
function getResultsList(dataList) {
  if (isObject(dataList)) {
    if (isArray(dataList)) {
      return dataList.map(function(v) {
        return v[0]; //v[0] contains full string
      });
    }
    else {
      /*
       * Example dataList:
       *
       * data: [{a: 10, b: ['dude', 'd', '', 'ude'], c:['dumb', 'd', '', 'umb']}, {a: 10, b: ['dude man', 'd', '', 'ude man'], c: null}]
       * searchInProps: ['b', 'c']
       */
      var tempDataList = clone(dataList);

      tempDataList.data = tempDataList.data.map(function(data) {
        tempDataList.searchInProps.forEach(function(key) {
          if (data[key]) data[key] = data[key][0];
        });
        return data;
      });
      return tempDataList;
    }
  }
  else throw new SyntaxError(messages.DataMustBeArrayOrObject);
}
688899
def load_json_dict(filename, *args):
	""""""
	data = {}
	if os.path.exists(filename):
		with open(filename, "r") as f:
			try:
				data = json.load(f)
				if not isinstance(data, dict):
					data = {}
			except:
				pass 
		if args:
			return {key: data[key] for key in args if key in data}
	return data
711929
function readKeys(force) {
    if (!force && options.cacheKeys) {
      return Promise.resolve(cachedKeys);
    }
    if (!force && options.cacheValues) {
      return Promise.resolve(Object.keys(cachedData));
    }

    return readdir(file).then(function(files) {
      var keys = [];

      files.forEach(function(filename) {
        if (filename.endsWith('.json')) {
          keys.push(filename.replace(/\.json$/, ''));
        }
      });

      return Promise.resolve(keys);
    });
  }
146370
function getComponentMetadataPath(filepath) {
	const extname = path.extname(filepath)
	return filepath.substring(0, filepath.length - extname.length) + '.json'
}
501244
public List<Object> getAllJsonPath(String json, String jsonPath) {
        List<Object> result;
        if (JsonPath.isPathDefinite(jsonPath)) {
            Object val = getJsonPath(json, jsonPath);
            if (val == null) {
                result = Collections.emptyList();
            } else {
                result = Collections.singletonList(val);
            }
        } else {
            result = parseJson(json).read(jsonPath);
        }
        return result;
    }
1186436
def generate_json_paths(self):
        """"""
        if isinstance(self.input_fields, basestring):
            try:
                self.jsonpaths = parse(self.input_fields)
            except Exception as exception:
                print "input_fields failed {}".format(self.input_fields)
                raise exception

        elif isinstance(self.input_fields, types.ListType):
            self.jsonpaths = list()
            for input_field in self.input_fields:
                self.jsonpaths.append(parse(input_field))
            if len(self.jsonpaths) == 1:
                self.jsonpaths = self.jsonpaths[0]
484616
def load_from_json(file_path):
    """"""
    if os.path.exists(file_path):
        raw_data = open(file_path, 'rb').read()
        return json.loads(base64.decodestring(raw_data).decode('utf-8'))
1073813
def get_dict_from_json_file(path, encoding='utf-8'):
    
    with open(path, encoding=encoding) as data_file:
        return json.loads(data_file.read())
16937
def _get(self):
        """"""

        data, stat = self.zk.get(self.path)
        if not len(data):
            return {}, stat.version
        if self.OLD_SEPARATOR in data:
            return self._get_old()
        return json.loads(data), stat.version
540305
public Object getDataJson(String path) throws ZooKeeperException {
        try {
            Object data = getFromCache(cacheNameJson, path);
            if (data == null) {
                data = _readJson(path);
                putToCache(cacheNameJson, path, data);
            }
            return data;
        } catch (ZooKeeperException.NodeNotFoundException e) {
            return null;
        } catch (Exception e) {
            if (e instanceof ZooKeeperException) {
                throw (ZooKeeperException) e;
            } else {
                throw new ZooKeeperException(e);
            }
        }
    }