JSON parser

@function fromJson
@param {Object} collection - collection model
@param {String} collectionPath - path of collection
@param {Function} next - callback
3144
function fromJson(collection, collectionPath, next) {

  var docsBulk = [];
  var docs = fs.readdirSync(collectionPath);
  var last = ~~docs.length, counter = 0;
  if (last === 0) {
    return next(null);
  }

  docs.forEach(function(docName) {

    var doc, data;
    try {
      data = fs.readFileSync(collectionPath + docName);
    } catch (err) {
      return last === ++counter ? next(null) : null;
    }
    try {
      doc = JSON.parse(data);
    } catch (err) {
      return last === ++counter ? next(err) : error(err);
    }

    docsBulk.push({
      insertOne: {
        document: doc
      }
    });

    return last === ++counter ? collection.bulkWrite(docsBulk, next) : null;
  });
}
893782
function readJSON (filePath) {
  let json = fs.readFileSync(filePath, "utf8");

  try {
    return JSON.parse(json);
  }
  catch (e) {
    throw ono(e, `Error parsing ${filePath}`);
  }
}
147912
public <T> Collection<T> collectAll(InputStream inputStream, Class<T> tClass, JsonPath... paths) {
        CollectAllListener<T> listener = new CollectAllListener<T>(jsonProvider, tClass);
        SurfingConfiguration.Builder builder = configBuilder();
        for (JsonPath jsonPath : paths) {
            builder.bind(jsonPath, listener);
        }
        surf(inputStream, builder.build());
        return listener.getCollection();
    }
585829
function parseJSON( path, content ) {

            return JSON.parse( content, function( key, value ) {

                if ( options.stripComments && key === "{{comment}}" ) return undefined;

                // Replace variables in their values

                if ( Object.keys( options.variables ).length && typeof value === "string" ) {
                    value = replaceVariables( value );
                }

                var match = ( typeof value === "string" ) ? value.match( options.parsePattern ) : null;

                if ( match ) {
                    var folderPath = getFolder( path ) || ".";
                    var fullPath = folderPath + "/" + match[ 1 ];

                    return isDirectory( fullPath ) ? parseDirectory( fullPath ) : parseFile( fullPath );
                }

                return value;

            } );
        }
1123737
function parseResource (err, responseSpec, next) {
      var resource = responseSpec ? responseSpec.body : undefined;
      this.invokeNext(err, resource, next);
    }
664369
function _setCollectionFrom(COLLECTION) {
	  _export(_export.S, COLLECTION, { from: function from(source /* , mapFn, thisArg */) {
	      var mapFn = arguments[1];
	      var mapping, A, n, cb;
	      _aFunction(this);
	      mapping = mapFn !== undefined;
	      if (mapping) _aFunction(mapFn);
	      if (source == undefined) return new this();
	      A = [];
	      if (mapping) {
	        n = 0;
	        cb = _ctx(mapFn, arguments[2], 2);
	        _forOf(source, false, function (nextItem) {
	          A.push(cb(nextItem, n++));
	        });
	      } else {
	        _forOf(source, false, A.push, A);
	      }
	      return new this(A);
	    } });
	}
340373
function getJSON(filepath) {
  const jsonString = "g = " + fs.readFileSync(filepath, 'utf8') + "; g";
  return (new vm.Script(jsonString)).runInNewContext();
}
706901
function deepCollection(collectionId, obj) {
  const pathBits = idKeys(collectionId);
  pathBits.pop();
  pathBits.push('collection');
  pathBits.shift();
  return deepObj(pathBits, obj, false);
}
184468
function readJson(filePath) {
    var json = {};

    try {
        var content = fs.readFileSync(path.resolve(process.cwd(), filePath), {
            encoding: 'utf-8'
        });
        json = JSON.parse(stripJsonComments(content));
    } catch (error) {
        console.error(error);
    }

    return json;
}
1161698
def _collection_json_response(cls, resources, start, stop, depth=0):
    

    top_level_json_name = None
    if cls.__top_level_json_name__ is not None:
        top_level_json_name = cls.__top_level_json_name__
    else:
        top_level_json_name = 'resources'

    result_list = []
    for resource in resources:
        result_list.append(resource.as_dict(depth))

    payload = {}
    if start is not None:
        payload[top_level_json_name] = result_list[start:stop]
    else:
        payload[top_level_json_name] = result_list

    return jsonify(payload)
53268
def from_json_file(cls, path):
        
        with open(path) as jsf:
            template_json = json.load(jsf)
            return cls(template_json=template_json)
1102348
def parse_json_path(self, jsonpath):

        
        if jsonpath not in self.parsed:
            try:
                self.parsed[jsonpath] = self.parser(jsonpath)
            except Exception:
                self.log("Invalid Json Path: " + jsonpath, "error")
                raise InvalidJsonPathError("Invalid Json Path")

        return self.parsed[jsonpath]
1072014
public Collection<Object> collectAll(String json, String... paths) {
        return collectAll(json, compile(paths));
    }
897781
def from_json(cls, path, fatal=True, logger=None):
        
        result = cls()
        result.load(path, fatal=fatal, logger=logger)
        return result
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;
    }
94792
@SuppressWarnings("unchecked")
    public <T> T collectOne(InputStream inputStream, Class<T> tClass, JsonPath... paths) {
        CollectOneListener listener = new CollectOneListener(true);
        SurfingConfiguration.Builder builder = configBuilder().skipOverlappedPath();
        for (JsonPath jsonPath : paths) {
            builder.bind(jsonPath, listener);
        }
        surf(inputStream, builder.build());
        Object value = listener.getValue();
        return tClass.cast(jsonProvider.cast(value, tClass));
    }
142222
function rJson(path, callback) {

    if (typeof callback === "function") {
        Fs.readFile(path, "utf-8", function (err, data) {
            try {
                data = JSON.parse(data);
            } catch (e) {
                err = err || e;
            }
            callback(err, data);
        });
        return;
    }

    return JSON.parse(Fs.readFileSync(path));
}