user1493834
user1493834

Reputation: 766

How to parse this JavaScript variable

This is not a valid JSON data. But I have to parse it to extract "isNavPaneDisabled". How do I parse it?

var text = {
    version: "1.8",
    viewid: "RegistrationPage",
    browserless: false,
    username: "system",
    userrole: "NonAdmin",
    message: "",
    productname: "someApp",
    isNavPaneDisabled: true,
    isDebug: false
};

Upvotes: 0

Views: 45

Answers (1)

Md Ashaduzzaman
Md Ashaduzzaman

Reputation: 4038

The following object isn't in JSON format, but still it's a javaScript object.

console.log(typeof text); // it says text is an object

So you can access the properties of that object. In your case try,

console.log(text.isNavPaneDisabled);

Upvotes: 3

Related Questions