JavaScript parse json

60 JavaScript code examples are found related to "parse json".
Example 1
Source File: util.js    From ashteki with GNU Affero General Public License v3.0 8 votes vote down vote up
export function tryParseJSON(jsonString) {
    try {
        var retObject = JSON.parse(jsonString);

        // Handle non-exception-throwing cases:
        // Neither JSON.parse(false) or JSON.parse(1234) throw errors, hence the type-checking,
        // but... JSON.parse(null) returns null, and typeof null === "object",
        // so we must check for that, too. Thankfully, null is falsey, so this suffices:
        if (retObject && typeof retObject === 'object') {
            return retObject;
        }
    } catch (e) {
        return false;
    }

    return false;
}
Example 2
Source File: request.js    From QiskitFlow with Apache License 2.0 8 votes vote down vote up
/**
 * Parses the JSON returned by a network request
 *
 * @param  {object} response A response from a network request
 *
 * @return {object}          The parsed JSON from the request
 */
function parseJSON(response) {
  if (response.status === 204 || response.status === 205) {
    return null;
  }
  return response.json();
}
Example 3
Source File: utils.js    From simple-bar with MIT License 8 votes vote down vote up
parseJson = (json) => {
  try {
    return JSON.parse(json)
  } catch (error) {
    // eslint-disable-next-line no-console
    console.error(error, json)
    return undefined
  }
}
Example 4
Source File: utils.js    From OpenDSU with MIT License 8 votes vote down vote up
/**
 * This method is decoding a JSON string and returns the JSON object
 * @param data {string}
 * @param keepBuffer {boolean}
 * @returns {Object|Error}
 */
function safeParseEncodedJson(data, keepBuffer = false) {
    try {
        return JSON.parse(base64UrlDecode(data, keepBuffer));
    } catch (e) {
        return e;
    }
}
Example 5
Source File: env.js    From Chuck with MIT License 8 votes vote down vote up
parse(configJson, parent = '') {
        Object.keys(configJson).forEach(key => {
            let newParent = '';
            if (parent != '') {
                newParent = parent + '_' + key.toUpperCase();
            } else {
                newParent = key.toUpperCase();
            }
            if (typeof configJson[key] === 'object') {
                this.parse(configJson[key], newParent);
            }
            else {
                this.assignValue(newParent, process.env[newParent]);
            }
        });

        return this.envConfig;
    }
Example 6
Source File: common-util.js    From ain-blockchain with MIT License 8 votes vote down vote up
static parseJsonOrNull(str) {
    let parsed = null;
    try {
      parsed = JSON.parse(str);
    } catch (e) {
      // parsed is not set
    }
    return parsed;
  }
Example 7
Source File: fetchRequest.js    From amazon-connect-chat-interface with MIT No Attribution 8 votes vote down vote up
/**
 * Parses the JSON returned by a network request
 *
 * @param  {object} response A response from a network request
 *
 * @return {object}          The parsed JSON, status from the response
 */
function parseJSON(response) {
  return new Promise((resolve) => response.json()
    .then((json) => resolve({
      status: response.status,
      ok: response.ok,
      json,
    })));
}
Example 8
Source File: utils.js    From _hyperscript with BSD 2-Clause "Simplified" License 8 votes vote down vote up
/**
 * parseJSON parses a JSON string into a corresponding value.  If the
 * value passed in is not valid JSON, then it logs an error and returns `null`.
 *
 * @param {string} jString
 * @returns any
 */
export function parseJSON(jString) {
	try {
		return JSON.parse(jString);
	} catch (error) {
		logError(error);
		return null;
	}
}
Example 9
Source File: common.js    From jscool with MIT License 8 votes vote down vote up
jsonParse(str) {
        try {
            return JSON.parse(str);
        } catch (e) {
            try {
                let data = this.match([/try\s*\{\w+\s*\(([^\)]+)/, /\w+\s*\(([^\)]+)/], str)
                return JSON.parse(data);
            } catch (ee) {
                try {
                    let cb = this.match(/try\s*\{\s*(\w+)/, str)
                    if (cb) {
                        let func = "";
                        let data = str.replace(cb, `func=`)
                        eval(data);
                        return func
                    }
                } catch (eee) {
                    return str
                }
            }
        }
    }
Example 10
Source File: utils.js    From YApi-X with MIT License 8 votes vote down vote up
/**
 * 作用:解析规则串 key ,然后根据规则串的规则以及路径找到在 json 中对应的数据
 * 规则串:$.{key}.{body||params}.{dataPath} 其中 body 为返回数据,params 为请求数据,datapath 为数据的路径
 * 数组:$.key.body.data.arr[0]._id  (获取 key 所指向请求的返回数据的 arr 数组的第 0 项元素的 _id 属性)
 * 对象:$.key.body.data.obj._id ((获取 key 所指向请求的返回数据的 obj 对象的 _id 属性))
 *
 * @param String key 规则串
 * @param Object json 数据
 * @returns
 */
function simpleJsonPathParse(key, json) {
  if (!key || typeof key !== 'string' || key.indexOf('$.') !== 0 || key.length <= 2) {
    return null
  }
  let keys = key.substr(2).split('.')
  keys = keys.filter(item => {
    return item
  })
  for (let i = 0, l = keys.length; i < l; i++) {
    try {
      const m = keys[i].match(/(.*?)\[([0-9]+)\]/)
      if (m) {
        json = json[m[1]][m[2]]
      } else {
        json = json[keys[i]]
      }
    } catch (e) {
      json = ''
      break
    }
  }

  return json
}
Example 11
Source File: data.js    From label-studio-frontend with Apache License 2.0 8 votes vote down vote up
tryToParseJSON = value => {
  if (isString(value) && value[0] === "{") {
    try {
      return JSON.parse(value);
    } catch (e) {
      // somthing went wrong
    }
  }

  return false;
}
Example 12
Source File: common.js    From hi-face with MIT License 8 votes vote down vote up
function safeJsonParse(jsonstr) {
  try {
    return JSON.parse(jsonstr)
  } catch (e) {
    // eslint-disable-next-line no-console
    console.warn(e)
    return {}
  }
}
Example 13
Source File: request.js    From bhanwari-devi-archive with GNU General Public License v3.0 8 votes vote down vote up
/**
 * Parses the JSON returned by a network request
 *
 * @param  {object} response A response from a network request
 *
 * @return {object}          The parsed JSON from the request
 */
function parseJSON(response) {
    if (response.status === 204 || response.status === 205) {
      return null;
    }
    return response.json();
  }
Example 14
Source File: fileHelpers.js    From watchmo with MIT License 8 votes vote down vote up
function readParseWriteJSON(readPath, parser, writePath) {
  fs.readFile(readPath, 'utf-8', (err, data) => {
    if (err) {
      console.log(chalk.red.bold.underline('Error reading file', err));
    } else {
      writeJSON(writePath, parser(data));
    }
  })
}
Example 15
Source File: request.js    From bank-client with MIT License 8 votes vote down vote up
/**
 * Parses the JSON returned by a network request
 *
 * @param  {object} response A response from a network request
 *
 * @return {object}          The parsed JSON from the request
 */
function parseJSON(response) {
  if (response.status === 204 || response.status === 205) {
    return null;
  }
  return response.json();
}
Example 16
Source File: util.js    From townsquare-client with MIT License 8 votes vote down vote up
export function tryParseJSON(jsonString) {
    try {
        var retObject = JSON.parse(jsonString);

        // Handle non-exception-throwing cases:
        // Neither JSON.parse(false) or JSON.parse(1234) throw errors, hence the type-checking,
        // but... JSON.parse(null) returns null, and typeof null === "object",
        // so we must check for that, too. Thankfully, null is falsey, so this suffices:
        if(retObject && typeof retObject === 'object') {
            return retObject;
        }
    } catch(e) {
        return false;
    }
    return false;
}
Example 17
Source File: utils.js    From orangutan-monorepo with MIT License 8 votes vote down vote up
/**
 * Read and parse the `package.json` into javascript object
 *
 * @param {string} packageDirname
 * @return {Object} parsed content of `package.json`
 */
function parsePackageJson(packageDirname) {
  // Cache the parsed value on runtime to reduce disk read
  if (!_.get(parsePackageJson, packageDirname)) {
    const packageJsonPath = path.resolve(
      constants.packagesAbsolutePath,
      packageDirname,
      'package.json'
    )
    const packageJsonObj = JSON.parse(fs.readFileSync(packageJsonPath))
    _.set(parsePackageJson, packageDirname, packageJsonObj)
  }
  return _.get(parsePackageJson, packageDirname)
}
Example 18
Source File: utils-xmlParser.js    From openos with MIT License 8 votes vote down vote up
async function parseXmlToJSON(xmldata, allowArray = false) {
    return new Promise(function (resolve, reject) {

        //url 정보에 &가 있으면 ParseError가 발생
        // &amp; 면 상관없읍

        var xml2js = require('xml2js');
        // explicitArray: 배열로 감싸지 않음, mergeAttrs: $ 객체 하위에 있는 속성을 부모 요소에 붙임.
        var parser = new xml2js.Parser({ explicitArray: allowArray, mergeAttrs: true });

        parser.parseString(xmldata, function (err, result) {
            if (err) {
                reject(err)
                return;
            }

            resolve(result);
        });
    });
}
Example 19
Source File: JDHelpers.js    From my_scripts with GNU General Public License v3.0 8 votes vote down vote up
function jsonParse(str) {
  if (typeof str == 'string') {
    try {
      return JSON.parse(str);
    } catch (e) {
      console.log(e);
      return [];
    }
  }
}
Example 20
Source File: utils.js    From 2019-nCov with GNU General Public License v3.0 8 votes vote down vote up
// It seems like some servers would return different MLME type for JSON so that it will be
// converted to JS objectdirectly. This is the helper function to check that.
//
function myJsonParse(text) {
  if ((typeof text) == "string") {
    var data = JSON.parse(text);
  } else {
    // Seems like on some servers (e.g. raw.githack.com) the JSON file would be converted to
    // Javascript Object directly.
    var data = text;
  }

  return data;
}
Example 21
Source File: utils.js    From 2019-nCov with GNU General Public License v3.0 8 votes vote down vote up
function testMyJsonParse() {
  let obj = {
    a: "A",
    b: "B",
  };

  let text = JSON.stringify(obj);

  EXPECT_EQ(JSON.stringify(obj), JSON.stringify(myJsonParse(text)));
  EXPECT_EQ(JSON.stringify(obj), JSON.stringify(myJsonParse(obj)));
}
Example 22
Source File: cesiumHelpers.js    From vue-cesium-v2 with MIT License 8 votes vote down vote up
/**
 * 解析 HierarchyJson
 * @param {Object} val
 */
function parsePolygonHierarchyJson (val, ellipsoid) {
  val.forEach((element) => {
    element.positions = makeCartesian3Array(element.positions, ellipsoid)
    if (element.holes) {
      parsePolygonHierarchyJson(element.holes, ellipsoid)
    }
  })
}
Example 23
Source File: request.js    From rtk-demo with MIT License 8 votes vote down vote up
/**
 * Parses the JSON returned by a network request
 *
 * @param  {object} response A response from a network request
 *
 * @return {object}          The parsed JSON from the request
 */
function parseJSON(response) {
  if (response.status === 204 || response.status === 205) {
    return null;
  }
  return response.json();
}
Example 24
Source File: jd_818.js    From jd_scripts with GNU General Public License v3.0 7 votes vote down vote up
function jsonParse(str) {
  if (typeof str == "string") {
    try {
      return JSON.parse(str);
    } catch (e) {
      console.log(e);
      $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie')
      return [];
    }
  }
}
Example 25
Source File: jd_apple_live.js    From jd_scripts with GNU General Public License v3.0 7 votes vote down vote up
function jsonParse(str) {
  if (typeof str == "string") {
    try {
      return JSON.parse(str);
    } catch (e) {
      console.log(e);
      $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie')
      return [];
    }
  }
}
Example 26
Source File: jd_digital_floor.js    From jd_scripts with GNU General Public License v3.0 7 votes vote down vote up
function jsonParse(str) {
  if (typeof str == "string") {
    try {
      return JSON.parse(str);
    } catch (e) {
      console.log(e);
      $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie')
      return [];
    }
  }
}
Example 27
Source File: jd_ds.js    From jd_scripts with GNU General Public License v3.0 7 votes vote down vote up
function jsonParse(str) {
  if (typeof str == "string") {
    try {
      return JSON.parse(str);
    } catch (e) {
      console.log(e);
      $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie')
      return [];
    }
  }
}
Example 28
Source File: jd_health.js    From jd_scripts with GNU General Public License v3.0 7 votes vote down vote up
function jsonParse(str) {
  if (typeof str == "string") {
    try {
      return JSON.parse(str);
    } catch (e) {
      console.log(e);
      $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie')
      return [];
    }
  }
}
Example 29
Source File: jd_jdh.js    From jd_scripts with GNU General Public License v3.0 7 votes vote down vote up
function jsonParse(str) {
  if (typeof str == "string") {
    try {
      return JSON.parse(str);
    } catch (e) {
      console.log(e);
      $.msg($.name, '', '不要在BoxJS手动复制粘贴修改cookie')
      return [];
    }
  }
}
Example 30
Source File: jd_jxstory.js    From jd_scripts with GNU General Public License v3.0 7 votes vote down vote up
function jsonParse(str) {
  if (typeof str == "string") {
    try {
      return JSON.parse(str);
    } catch (e) {
      console.log(e);
      $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie')
      return [];
    }
  }
}
Example 31
Source File: jd_live_redrain.js    From jd_scripts with GNU General Public License v3.0 7 votes vote down vote up
function jsonParse(str) {
  if (typeof str == "string") {
    try {
      return JSON.parse(str);
    } catch (e) {
      console.log(e);
      $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie')
      return [];
    }
  }
}
Example 32
Source File: jd_ms_redrain.js    From jd_scripts with GNU General Public License v3.0 7 votes vote down vote up
function jsonParse(str) {
  if (typeof str == "string") {
    try {
      return JSON.parse(str);
    } catch (e) {
      console.log(e);
      $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie')
      return [];
    }
  }
}
Example 33
Source File: jd_pubg.js    From jd_scripts with GNU General Public License v3.0 7 votes vote down vote up
function jsonParse(str) {
  if (typeof str == "string") {
    try {
      return JSON.parse(str);
    } catch (e) {
      console.log(e);
      $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie')
      return [];
    }
  }
}
Example 34
Source File: jd_split.js    From jd_scripts with GNU General Public License v3.0 7 votes vote down vote up
function jsonParse(str) {
  if (typeof str == "string") {
    try {
      return JSON.parse(str);
    } catch (e) {
      console.log(e);
      $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie')
      return [];
    }
  }
}
Example 35
Source File: jd_watch.js    From jd_scripts with GNU General Public License v3.0 7 votes vote down vote up
function jsonParse(str) {
  if (typeof str == "string") {
    try {
      return JSON.parse(str);
    } catch (e) {
      console.log(e);
      $.msg($.name, '', '不要在BoxJS手动复制粘贴修改cookie')
      return [];
    }
  }
}
Example 36
Source File: jd_xtg.js    From jd_scripts with GNU General Public License v3.0 7 votes vote down vote up
function jsonParse(str) {
  if (typeof str == "string") {
    try {
      return JSON.parse(str);
    } catch (e) {
      console.log(e);
      $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie')
      return [];
    }
  }
}
Example 37
Source File: jr_sign.js    From jd_scripts with GNU General Public License v3.0 7 votes vote down vote up
function jsonParse(str) {
  if (typeof str == "string") {
    try {
      return JSON.parse(str);
    } catch (e) {
      console.log(e);
      $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie')
      return [];
    }
  }
}
Example 38
Source File: jd_bean_change.js    From jd_scripts with GNU General Public License v3.0 7 votes vote down vote up
function jsonParse(str) {
  if (typeof str == "string") {
    try {
      return JSON.parse(str);
    } catch (e) {
      console.log(e);
      $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie')
      return [];
    }
  }
}
Example 39
Source File: jd_bean_home.js    From jd_scripts with GNU General Public License v3.0 7 votes vote down vote up
function jsonParse(str) {
  if (typeof str == "string") {
    try {
      return JSON.parse(str);
    } catch (e) {
      console.log(e);
      $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie')
      return [];
    }
  }
}
Example 40
Source File: jd_bean_home_twogen.js    From jd_scripts with GNU General Public License v3.0 7 votes vote down vote up
function jsonParse(str) {
  if (typeof str == "string") {
    try {
      return JSON.parse(str);
    } catch (e) {
      console.log(e);
      $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie')
      return [];
    }
  }
}
Example 41
Source File: jd_bj.js    From jd_scripts with GNU General Public License v3.0 7 votes vote down vote up
function jsonParse(str) {
  if (typeof str == "string") {
    try {
      return JSON.parse(str);
    } catch (e) {
      console.log(e);
      $.msg($.name, '', '不要在BoxJS手动复制粘贴修改cookie')
      return [];
    }
  }
}
Example 42
Source File: jd_blueCoin.js    From jd_scripts with GNU General Public License v3.0 7 votes vote down vote up
function jsonParse(str) {
  if (typeof str == "string") {
    try {
      return JSON.parse(str);
    } catch (e) {
      console.log(e);
      $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie')
      return [];
    }
  }
}
Example 43
Source File: jd_bookshop_twogen.js    From jd_scripts with GNU General Public License v3.0 7 votes vote down vote up
function jsonParse(str) {
  if (typeof str == "string") {
    try {
      return JSON.parse(str);
    } catch (e) {
      console.log(e);
      $.msg($.name, '', '不要在BoxJS手动复制粘贴修改cookie')
      return [];
    }
  }
}
Example 44
Source File: jd_car.js    From jd_scripts with GNU General Public License v3.0 7 votes vote down vote up
function jsonParse(str) {
  if (typeof str == "string") {
    try {
      return JSON.parse(str);
    } catch (e) {
      console.log(e);
      $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie')
      return [];
    }
  }
}
Example 45
Source File: jd_car_exchange.js    From jd_scripts with GNU General Public License v3.0 7 votes vote down vote up
function jsonParse(str) {
  if (typeof str == "string") {
    try {
      return JSON.parse(str);
    } catch (e) {
      console.log(e);
      $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie')
      return [];
    }
  }
}
Example 46
Source File: jd_cash_twogen.js    From jd_scripts with GNU General Public License v3.0 7 votes vote down vote up
function jsonParse(str) {
  if (typeof str == "string") {
    try {
      return JSON.parse(str);
    } catch (e) {
      console.log(e);
      $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie')
      return [];
    }
  }
}
Example 47
Source File: jd_club_lottery.js    From jd_scripts with GNU General Public License v3.0 7 votes vote down vote up
function jsonParse(str) {
  if (typeof str == "string") {
    try {
      return JSON.parse(str);
    } catch (e) {
      console.log(e);
      $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie')
      return [];
    }
  }
}
Example 48
Source File: jd_crazy_joy.js    From jd_scripts with GNU General Public License v3.0 7 votes vote down vote up
function jsonParse(str) {
  if (typeof str == "string") {
    try {
      return JSON.parse(str);
    } catch (e) {
      console.log(e);
      $.msg($.name, '', '不要在BoxJS手动复制粘贴修改cookie')
      return [];
    }
  }
}
Example 49
Source File: jd_crazy_joy_coin.js    From jd_scripts with GNU General Public License v3.0 7 votes vote down vote up
function jsonParse(str) {
  if (typeof str == "string") {
    try {
      return JSON.parse(str);
    } catch (e) {
      console.log(e);
      $.msg($.name, '', '不要在BoxJS手动复制粘贴修改cookie')
      return [];
    }
  }
}
Example 50
Source File: jd_crazy_joy_twogen.js    From jd_scripts with GNU General Public License v3.0 7 votes vote down vote up
function jsonParse(str) {
  if (typeof str == "string") {
    try {
      return JSON.parse(str);
    } catch (e) {
      console.log(e);
      $.msg($.name, '', '不要在BoxJS手动复制粘贴修改cookie')
      return [];
    }
  }
}
Example 51
Source File: jd_daily_egg.js    From jd_scripts with GNU General Public License v3.0 7 votes vote down vote up
function jsonParse(str) {
  if (typeof str == "string") {
    try {
      return JSON.parse(str);
    } catch (e) {
      console.log(e);
      $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie')
      return [];
    }
  }
}
Example 52
Source File: jd_dreamFactory.js    From jd_scripts with GNU General Public License v3.0 7 votes vote down vote up
function jsonParse(str) {
  if (typeof str == "string") {
    try {
      return JSON.parse(str);
    } catch (e) {
      console.log(e);
      $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie')
      return [];
    }
  }
}
Example 53
Source File: jd_dreamFactory_twogen.js    From jd_scripts with GNU General Public License v3.0 7 votes vote down vote up
function jsonParse(str) {
  if (typeof str == "string") {
    try {
      return JSON.parse(str);
    } catch (e) {
      console.log(e);
      $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie')
      return [];
    }
  }
}
Example 54
Source File: jd_get_share_code.js    From jd_scripts with GNU General Public License v3.0 7 votes vote down vote up
function jsonParse(str) {
  if (typeof str == "string") {
    try {
      return JSON.parse(str);
    } catch (e) {
      console.log(e);
      $.msg($.name, '', '不要在BoxJS手动复制粘贴修改cookie')
      return [];
    }
  }
}
Example 55
Source File: jd_gyec_twogen.js    From jd_scripts with GNU General Public License v3.0 7 votes vote down vote up
function jsonParse(str) {
  if (typeof str == "string") {
    try {
      return JSON.parse(str);
    } catch (e) {
      console.log(e);
      $.msg($.name, '', '不要在BoxJS手动复制粘贴修改cookie')
      return [];
    }
  }
}
Example 56
Source File: jd_health_twogen.js    From jd_scripts with GNU General Public License v3.0 7 votes vote down vote up
function jsonParse(str) {
  if (typeof str == "string") {
    try {
      return JSON.parse(str);
    } catch (e) {
      console.log(e);
      $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie')
      return [];
    }
  }
}
Example 57
Source File: jd_jdfactory.js    From jd_scripts with GNU General Public License v3.0 7 votes vote down vote up
function jsonParse(str) {
  if (typeof str == "string") {
    try {
      return JSON.parse(str);
    } catch (e) {
      console.log(e);
      $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie')
      return [];
    }
  }
}
Example 58
Source File: jd_jdzz.js    From jd_scripts with GNU General Public License v3.0 7 votes vote down vote up
function jsonParse(str) {
  if (typeof str == "string") {
    try {
      return JSON.parse(str);
    } catch (e) {
      console.log(e);
      $.msg($.name, '', '不要在BoxJS手动复制粘贴修改cookie')
      return [];
    }
  }
}
Example 59
Source File: jd_jdzz_twogen.js    From jd_scripts with GNU General Public License v3.0 7 votes vote down vote up
function jsonParse(str) {
  if (typeof str == "string") {
    try {
      return JSON.parse(str);
    } catch (e) {
      console.log(e);
      $.msg($.name, '', '不要在BoxJS手动复制粘贴修改cookie')
      return [];
    }
  }
}
Example 60
Source File: jd_joy.js    From jd_scripts with GNU General Public License v3.0 7 votes vote down vote up
function jsonParse(str) {
  if (typeof str == "string") {
    try {
      return JSON.parse(str);
    } catch (e) {
      console.log(e);
      $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie')
      return [];
    }
  }
}