Dive into secure and efficient coding practices with our curated list of the top 10 examples showcasing 'json' in functional components in JavaScript. Our advanced machine learning engine meticulously scans each line of code, cross-referencing millions of open source libraries to ensure your implementation is not just functional, but also robust and secure. Elevate your React applications to new heights by mastering the art of handling side effects, API calls, and asynchronous operations with confidence and precision.
}
// check classname
const cls = db.models[classname];
if (cls === undefined)
return fill_error(req, err_info(4040001, {
classname: classname
}));
var _req = {
session: req.session,
query: req.query.toJSON(),
request: req
};
var where = _req.query.where;
if (where !== undefined)
try {
_req.query.where = json.decode(where);
}
catch (e) {
return fill_error(req, err_info(4000003));
}
var keys = _req.query.keys;
if (keys !== undefined && typeof keys === 'string')
_req.query.keys = keys.split(',');
var result;
try {
result = func.apply(undefined, [_req, db, cls].concat(earg, [data]));
}
catch (e) {
console.error(e.stack);
if (e.type === 'validation') {
result = {
error: {
_saveToBrowser: function () {
var flag = true;
try {
oIeOffline.setAttribute(TIME_DEADLINE, Json.stringify(oDeadline));
oIeOffline.setAttribute(SINGLE_KEY, Json.stringify(oGlobal));
oIeOffline.save(IE_OFFLINE);
} catch (e) {
// 磁盘已满或权限不足等问题
flag = false;
}
return flag;
}
}); //re.init();
var parts = fs.split(entry.getName());
parts.shift(); // name-project-comment ref dirname
var path = targetPath.join(fs.join.apply(null, parts));
path.dirname().mkdirs();
notes[name].files.push(path);
print(" + " + path);
path.write(entry.read('b'), 'b');
});
}
// write package.json if it was not in the
// archive
var packageJson = targetPath.join('package.json');
if (!packageJson.isFile())
packageJson.write(
json.encode(catalog.packages[name], null, 4),
{'charset': 'UTF-8'}
);
// make bins executable and make symlinks
// in $SEA/bin
var bin = targetPath.join('bin');
if (bin.isDirectory())
bin.list().forEach(function (name) {
var target = targetPath.join('bin', name);
target.chmod(0755);
var sea = tusk.getDirectory().join('bin');
var source = sea.join(name);
var relative = sea.to(target);
if (!source.linkExists() && !source.exists()) {
target.symlink(source);
}
var parts = fs.split(entry.getName());
parts.shift(); // name-project-comment ref dirname
var path = targetPath.join(fs.join.apply(null, parts));
path.dirname().mkdirs();
notes[name].files.push(path);
print(" + " + path);
path.write(entry.read('b'), 'b');
});
}
// write package.json if it was not in the
// archive
var packageJson = targetPath.join('package.json');
if (!packageJson.isFile())
packageJson.write(
json.encode(catalog.packages[name], null, 4),
{'charset': 'UTF-8'}
);
// make bins executable and make symlinks
// in $SEA/bin
var bin = targetPath.join('bin');
if (bin.isDirectory())
bin.list().forEach(function (name) {
var target = targetPath.join('bin', name);
target.chmod(0755);
var sea = tusk.getDirectory().join('bin');
var source = sea.join(name);
var relative = sea.to(target);
if (!source.linkExists() && !source.exists()) {
target.symlink(source);
}
#!/usr/bin/env node
// (C) Andrea Giammarchi - @WebReflection (ISC)
var path = require('path');
try {
var json = path.resolve('./package.json');
var package = require(json);
// be sure collective is there and refers to lightercollective
var collective = (
(package.dependencies || {}).lightercollective ||
(package.devDependencies || {}).lightercollective
) && package.collective;
if (
!collective ||
-1 < ['silent', 'error', 'warn'].indexOf(process.env.npm_config_loglevel) ||
/^(?:1|true|yes|y)$/i.test(process.env.DISABLE_OPENCOLLECTIVE)
) {
throw 0;
}
if (collective.logo) {
if (/^(https?):/.test(collective.logo))
require(RegExp.$1)
.get(collective.logo, function (response) {
if (response.statusCode === 200) {
response.setEncoding('utf8');
var data = [];
response.on('data', function (chunk) { data.push(chunk); });
response.on('end', function () { showLogo(data.join('')) });
#!/usr/bin/env node
// (C) Andrea Giammarchi - @WebReflection (ISC)
var path = require('path');
try {
var json = path.resolve('./package.json');
var package = require(json);
// be sure collective is there and refers to lightercollective
var collective = (
(package.dependencies || {}).lightercollective ||
(package.devDependencies || {}).lightercollective
) && package.collective;
if (
!collective ||
-1 < ['silent', 'error', 'warn'].indexOf(process.env.npm_config_loglevel) ||
/^(?:1|true|yes|y)$/i.test(process.env.DISABLE_OPENCOLLECTIVE)
) {
throw 0;
}
if (collective.logo) {
if (/^(https?):/.test(collective.logo))
require(RegExp.$1)
.get(collective.logo, function (response) {
if (response.statusCode === 200) {
response.setEncoding('utf8');
var data = [];
#!/usr/bin/env node
// (C) Andrea Giammarchi - @WebReflection (ISC)
var path = require('path');
try {
var json = path.resolve('./package.json');
var package = require(json);
// be sure collective is there and refers to lightercollective
var collective = (
(package.dependencies || {}).lightercollective ||
(package.devDependencies || {}).lightercollective
) && package.collective;
if (
!collective ||
-1 < ['silent', 'error', 'warn'].indexOf(process.env.npm_config_loglevel) ||
/^(?:1|true|yes|y)$/i.test(process.env.DISABLE_OPENCOLLECTIVE)
) {
throw 0;
}
if (collective.logo) {
if (/^(https?):/.test(collective.logo))
require(RegExp.$1)
.get(collective.logo, function (response) {
if (response.statusCode === 200) {
response.setEncoding('utf8');
var data = [];
response.on('data', function (chunk) { data.push(chunk); });
if (index > -1) {
store.splice(index, 1);
}
break;
case 'update':
id = self.get('id');
index = findById(store, id);
if (index > -1) {
store[index] = self.toJSON();
}
break;
}
if (method !== 'read' && window.localStorage) {
try {
window.localStorage.setItem(KEY, Json.stringify(store));
} catch (e) {
// QUOTA_EXCEEDED_ERR
S.log(e, 'error');
}
}
STORE = store;
if (error) {
if (options.error) {
options.error(null, error);
}
}
else if (options.success) {
options.success(ret);
_getDrafts: function () {
var self = this;
if (!self.drafts) {
var str = localStorage.getItem(self._getSaveKey()),
drafts = [];
if (str) {
// 原生 localStorage 必须串行化
drafts = (localStorage === window.localStorage) ?
Json.parse(util.urlDecode(str)) : str;
}
self.drafts = drafts;
}
return self.drafts;
},
// use an old one if it's no longer available
log.error("Unable to download a fresh copy of catalog " + url + ".");
}
}
// try to read the downloaded or stale copy
try {
var json = httpStore.read(url, {"charset": "UTF-8"});
} catch (exception) {
log.error("HttpError getting " + url + ".");
return;
}
// try to parse the source file
try {
include = JSON.decode(json);
} catch (exception) {
log.error("SyntaxError in " + url + ".");
return;
}
if (include.version < TUSK.minCatalogVersion) {
log.error("Catalog at " + url + " is obsolete.");
return;
}
catalogs[url] = include;
include.url = url;
// validate the catalog
// transitively grab sub-catalogs
exports.getCatalogs(include, catalogs, order, useCache, log);
});