0

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.

1
  • objConfig.import[0].pagestatus Commented Mar 12, 2015 at 11:14

2 Answers 2

2

use below code

 objConfig.import[0].pagestatus

it will give value of pagestatus inside import

Sign up to request clarification or add additional context in comments.

Comments

0

Use this:

var resp = jQuery.parseJSON(resp);
var drive =  resp.import.drive;
alert(drive);

3 Comments

"var drive = resp.import.drive;" really!!
var drive = resp.import.pagestatus;
@HarpartapSinghPermar import is an array so either you target the values from indexes or use a loop to get it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.