Hi,
I am Wondering what the best way to access properties deep in object?
for example below i have an object that gets returned from an API
The information i want to pick out is the Account name ( In [B] tags ) and then all the product codes listed under that (also in [B] tags). I was able to do it with loops inside loops (like 3 internal loops :x ) But think there may be a more efficent way.
object QueryResult(4) {
public queryLocator => NULL
public done => bool TRUE
public records => array(2) (
0 => object SObject(4) {
public type => string(11) "Opportunity"
public fields => object stdClass(3) {
public Name => string(8) "Test Opp"
public Id => string(18) "0063000000mSTvhAAG"
public Account => object SObject(2) {
public type => string(7) "Account"
public fields => object stdClass(1) {
public [B]Name[/B] => string(16) "Some Account"
}
}
}
public Id => string(18) "0063000000mSTvhAAG"
public queryResult => array(1) (
0 => object QueryResult(4) {
public queryLocator => NULL
public done => bool TRUE
public records => array(3) (
0 => object SObject(2) {
public type => string(19) "OpportunityLineItem"
public fields => object stdClass(2) {
public Quantity => string(3) "1.0"
public PricebookEntry => object SObject(2) {
public type => string(14) "PricebookEntry"
public fields => object stdClass(1) {
public [B]ProductCode[/B] => string(5) "12345"
}
}
}
}
1 => object SObject(2) {
public type => string(19) "OpportunityLineItem"
public fields => object stdClass(2) {
public Quantity => string(3) "1.0"
public PricebookEntry => object SObject(2) {
public type => string(14) "PricebookEntry"
public fields => object stdClass(1) {
public [B]ProductCode[/B] => string(6) "4565"
}
}
}
}
2 => object SObject(2) {
public type => string(19) "OpportunityLineItem"
public fields => object stdClass(2) {
public Quantity => string(3) "1.0"
public PricebookEntry => object SObject(2) {
public type => string(14) "PricebookEntry"
public fields => object stdClass(1) {
public [B]ProductCode[/B] => string(6) "23453"
}
}
}
}
)
public size => integer 3
}
)
}
1 => object SObject(4) {
public type => string(11) "Opportunity"
public fields => object stdClass(3) {
public Name => string(36) "Opp Name"
public Id => string(18) "0063000000mSVpQAAW"
public Account => object SObject(2) {
public type => string(7) "Account"
public fields => object stdClass(1) {
public Name => string(16) "Some Account"
}
}
}
public Id => string(18) "0063000000mSVpQAAW"
public queryResult => array(1) (
0 => object QueryResult(4) {
public queryLocator => NULL
public done => bool TRUE
public records => array(1) (
0 => object SObject(2) {
public type => string(19) "OpportunityLineItem"
public fields => object stdClass(2) {
public Quantity => string(3) "1.0"
public PricebookEntry => object SObject(2) {
public type => string(14) "PricebookEntry"
public fields => object stdClass(1) {
public [B]ProductCode[/B] => string(6) "56785"
}
}
}
}
)
public size => integer 1
}
)
}
)
public size => integer 2
}
Thanks in advanced!