I have an object that contains sub properties, which also have sub properties and so on.
I basically need to find the best way to retrieve the value of a particular field on the object, given it’s full hierarchical path as a string.
For example, if the object has the field company (Object) which has the field client (Object) which has the field id (String), this path will be represented as company.client.id. Therefore, given a path to the field i’m trying to get the value of on an object, how would I go about doing this?
Cheers.
Please find below
Fieldhelperclass withgetFieldValuemethod.It should allow you to solve your problem pretty quickly by
splitting your string and then applying the the
getFieldValuerecursively, taking the result object as input for the next step.