Reputation: 62
I have the following JSON which I keep in strConfig
variable:
{
"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:
console.log($(objConfig).find('export').find('pagestatus').value);
but that gives me 'undefined' in console. Any help will be appreciated.
Upvotes: 0
Views: 49
Reputation: 289
Use this:
var resp = jQuery.parseJSON(resp);
var drive = resp.import.drive;
alert(drive);
Upvotes: 0
Reputation: 6031
use below code
objConfig.import[0].pagestatus
it will give value of pagestatus inside import
Upvotes: 2