JSON.js

  1. /**
  2. * @namespace JSON
  3. */
  4. /**
  5. * Returns verdict if given string is valid JSON or not
  6. *
  7. * @memberof JSON
  8. * @param {string} str JSON string to be checked
  9. * @returns {boolean} Verdict
  10. */
  11. function isJSONString(str) {
  12. try {
  13. JSON.parse(str);
  14. } catch {
  15. return false;
  16. }
  17. return true;
  18. }
  19. export default {
  20. static: {
  21. isJSONString
  22. }
  23. };