js判断字符串是否json格式
2024-08-28 18:48:40
function isJSON(str) {
if (typeof str == 'string') {
try {
var obj=JSON.parse(str);
if(typeof obj == 'object' && obj ){
return true;
}else{
return false;
} } catch(e) {
console.log('error:'+str+'!!!'+e);
return false;
}
}
console.log('It is not a string!')
}
最新文章
- 随笔jade
- 权重轮询调度算法(WeightedRound-RobinScheduling)-Java实现2
- GPS部标平台的架构设计(二) 可扩展性设计
- HDU1502/Luogu1352/UVa1220 party[树形DP]
- thrift之TTransport层的分帧传输类TFramedTransport
- java 日期格式转换EEE MMM dd HH:mm:ss z yyyy
- 一个UUID生成算法的C语言实现 --- WIN32版本 .
- Zookeeper运维经验
- How to: Signing Installers You Create with Inno Setup
- Unity 图片分割将spirte保存在本地
- TelephonyManager
- Request processing failed; nested exception is org.springframework.dao.InvalidDataAccessApiUsageException: Multiple representations of the same entity解决方法
- Openjudge-NOI题库-Pell数列
- 计算机学院大学生程序设计竞赛(2015’12) 1004 Happy Value
- Android--多线程之Handler 前言
- NDK各个版本链接
- netty源码分析
- /etc/fstab文件出错,无法进入Linux系统
- IBM developer:Kafka ACLs
- springboot接口返回封装与异常控制
热门文章
- 设计模式之装饰模式(iOS开发,代码用Objective-C展示)
- C# 跳转新页面
- mac OS X中升级php5.5至php5.6 or php7
- [note]Why I haven’t quit my corporate job (yet)
- How to Use updateConstraints(什么时候该使用updateConstraints)
- mac键盘图表大全
- GridView Print and Print Preview
- USB2.0学习笔记连载(十九):EZ-USB TRM手册重要部分介绍
- 相似变换 SimilarityTransform 以及skimage源码
- Spring面试,IoC和AOP的理解