当前位置:网站首页>The JSON string is converted into a JSON object, the value of a key is obtained, and whether a key exists is judged
The JSON string is converted into a JSON object, the value of a key is obtained, and whether a key exists is judged
2022-07-26 22:34:00 【abs(ln(1+NaN))】
front end vue When passing data of an object type to the backend , The front end first converts the object into json character string , And then pass it to the back end , At this point, the backend needs to parse this json Word string , And take out the corresponding attribute value .
1、JSON String to JSON object
import com.alibaba.fastjson.JSONObject;
String jsonStr = "{\"id\": 2," +
" \"title\": \"json title\", " +
"\"config\": {" +
"\"width\": 34," +
"\"height\": 35," +
"}, \"data\": [" +
"\"JAVA\", \"JavaScript\", \"PHP\"" +
"]}";
// take json String to json object
JSONObject jsonobj = JSONObject.parseObject(jsonStr);![]()
2、 Get the value of a property
// there id yes json The key name of the object
String value = jsonobj.getString("data");
3、 Judge a certain key Whether there is
import com.alibaba.fastjson.JSONObject;
jsonobj.containsKey("message"); // If there is key be known as "message" , return true; Otherwise return to false边栏推荐
- Redis distributed lock + Lua atomic operation
- Blog Garden beautification skills summary
- A13处理器成iPhone11系列最大亮点:性能是麒麟980两倍!
- Makefile related syntax summary (openc910)
- Introduction to the notes of learning cesium by yourself
- Interview Essentials
- Sell 700million a year, and get ready for the IPO of Dezhou braised chicken
- [IO Development Notes] smart cloud intelligent watering device practice (1) - Basic demo implementation
- 2022-07-26:以下go语言代码输出什么?A:5;B:hello;C:编译错误;D:运行错误。 package main import ( “fmt“ )
- 判断numpy array数组的维数
猜你喜欢

SQL二次注入详解

JSON字符串转化为JSON对象,获取某个key的值,判断某个key是否存在

VCS编译、仿真过程

【Io开发笔记】机智云智能浇花器实战(3)-自动生成代码移植
![[IO Development Notes] smart cloud intelligent watering device practice (1) - Basic demo implementation](/img/db/122cc54ad8b5b06c885d7455ecb034.png)
[IO Development Notes] smart cloud intelligent watering device practice (1) - Basic demo implementation

Liepin questionnaire star has become a "parasite" on wechat

09.01 depth first search

缓存数据库Memcached

7.27抢先看 | openEuler 志高远,开源汇智创未来-开放原子全球开源峰会欧拉分论坛最详细议程出炉

Five years after graduation, I changed from information management to software testing engineer, and my monthly salary finally exceeded 12K
随机推荐
苹果iPhone11系列的秘密武器:U1芯片或将开启超宽带时代
Weilai cup 2022 Niuke summer multi school training camp 1
Do you know why to design test cases after learning so long about use case design
JWT implements login authentication + token automatic renewal scheme, which is the correct posture!
华为Atlas900揭秘:集成数千颗昇腾910芯片,算力堪比50万台PC!
基于gRPC编写golang简单C2远控
『Mysql』汇总Mysql索引失效的常见场景
三星Galaxy Z可折叠产品的预告片泄露:'柔性好于平面'
Jd.com won the highest award for intelligent science and technology in China! Inventory JD system intelligent technology
Classification of banking business
NVIDIA SMI error: NVIDIA SMI has failed because it could't communicate with the NVIDIA driver complete record
Embedded SIG | 分布式软总线
Is it safe to open an account for flush mobile stock trading? How to open an account
浮动引起的高度塌陷问题
华为密谋收购巴西运营商?
判断numpy array数组的维数
『IDEA』IDEA快捷键使用教程
Redis distributed lock + Lua atomic operation
Linear DP of dynamic programming
模块8(消息队列存储消息数据的mysql表格)