I have the following JSON which I keep in strConfig
variable:
我有以下JSON,我保留在strConfig变量中:
{
"import": [
{
"drive": "F",
"path": "F:\\\\PageExports\\\\",
"pagestatus": "1",
"withnextpages": "1"
}
],
"export": [
{
"drive": "F",
"path": "F:\\\\PageExports\\\\",
"followmainlink": "0"
}
]
}
I transorm it to an object by:
我通过以下方式将其转换为对象:
var objConfig = jQuery.parseJSON( strConfig );
Could you tell me how do I get one of values from that object and assign it to a variable, please (let's say value of import.pagestatus
)? I tried:
你能告诉我如何从该对象中获取一个值并将其分配给变量(请说出import.pagestatus的值)?我试过了:
console.log($(objConfig).find('export').find('pagestatus').value);
but that gives me 'undefined' in console. Any help will be appreciated.
但这让我在控制台中“未定义”。任何帮助将不胜感激。
2 个解决方案
#1
2
use below code
使用下面的代码
objConfig.import[0].pagestatus
it will give value of pagestatus inside import
它将在导入内给出pagestatus的值
#2
0
Use this:
var resp = jQuery.parseJSON(resp);
var drive = resp.import.drive;
alert(drive);
#1
2
use below code
使用下面的代码
objConfig.import[0].pagestatus
it will give value of pagestatus inside import
它将在导入内给出pagestatus的值
#2
0
Use this:
var resp = jQuery.parseJSON(resp);
var drive = resp.import.drive;
alert(drive);