PP.getProperty

Syntax

getProperty(context: Object, selector: String, asPPObj: Boolean);

Parameters

context. Source JSON object.

selector. String that contains a sequence of nested properties.

Description

The getProperty method determines value of a nested property of JSON object.

Comments

If a nested object does not exist this method returns the undefined value.

Example

To execute the example, add a link to PP.js scenario file to HTML page. Create an object, next set and show values of new properties for the nested object:

// Determine object
var chartView = {
    chartType: "pie"
};
if (PP.isObject(chartView)) {
    // Determine values of the width and height properties
    PP.setValueToJSON(10, chartView, "options.size.width");
    PP.setValueToJSON(20, chartView, "options.size.height");
    // Get values of the width and height properties
    console.log("Value of the width property: " + PP.getProperty(chartView, "options.size.width"));
    console.log("Value of the height property: " + PP.getProperty(chartView, "options.size.height"));
} else {
    console.log("The specified value is not an object.");
};

After executing the example the browser console displays values of new properties (width and height) nested in the source object:

Value of the width property: 10

Value of the height property: 20

See also:

PP