Is String json Parseable - Node.js Object

Node.js examples for Object:Json

Description

Is String json Parseable

Demo Code

JSON.isParseable = function(str) {
  // to do: if true, save result in cache
  try {/*from  w w w.java  2s. co  m*/
    JSON.parse(str);
    return true;
  } catch(e) {
    return false;
  }
};

Related Tutorials