Java教程

java 操作json

本文主要是介绍java 操作json,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
{
    "conversationId": "cid17PxV+L9tQGSnS3pMQNRMw==",
    "atUsers": [
        {
            "dingtalkId": "$:LWCP_v1:$J8oaMSWAlr76svNir8LD6YwqM/Aa+6eo"
        }
    ],
    "chatbotUserId": "$:LWCP_v1:$J8oaMSWAlr76svNir8LD6YwqM/Aa+6eo",
    "msgId": "msgCQfjQC2acf/VNBZoK0mqQg==",
    "senderNick": "凯宾斯基",
    "isAdmin": false,
    "sessionWebhookExpiredTime": 1650059346028,
    "createAt": 1650053945855,
    "conversationType": "2",
    "senderId": "$:LWCP_v1:$UENgJ9RNsle+pcvbHr6cCA==",
    "conversationTitle": "群消息应答-TEST",
    "isInAtList": true,
    "sessionWebhook": "https://xxxxx.com/sendBySessionXXXX",
    "text": {
        "content": " 你号啊"
    },
    "robotCode": "normal",
    "msgtype": "text"
}

 

 

获取上面json里面text 里 content 的值 

replaceAll是替换API

如果获取的键里面的值还是json 那么要用getJSONOBJect

String content = json.getJSONObject("text").get("content").toString().replaceAll(" ", "");
这篇关于java 操作json的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!