尝试获取 JSON 对象的值

try to get the value of json object

本文关键字:对象 JSON 获取      更新时间:2023-09-26

我有一个 ajaxpost 以 json 的形式返回响应,我想显示消息

{ "TEXT" : "Please fix it. there might be otehr reason, and need to address it, or call, incorrect username/password-username/port?. " } 

如何获取 json 的值?我使用了以下内容,但消息未定义,获取 json 对象的其他方法是什么

var TEXT = text.resp;

包含此库和下面的代码来解析您的 json

var json = $.parseJSON(obj.responseText);
var msg = json.message;

您也可以尝试以下代码

var json = JSON.parse(obj.responseText);
var msg = json.message;

您应该尝试解析对象,然后使用 json["object"] 而不是点访问它。