You need to sign in to do that
Don't have an account?
ChrisYaz
Getting field values in Apex from an Object (not an Sobject)?
I am integrating with a managed package that returns an Object, not an Sobject, but a plain Object in Apex. Using System.Debug the following is shown:
{nbrRows=1, rowIds=()}
I want to parse this returned data so that I can extract specific values from the object such as "nbrRows". I have already tried "JSON.deserializeUntyped" but due to the format not being typical JSON this did not work. I also tried "getPopulatedFieldsAsMap" but learn that this only works with SObjects, not an object.
Is there a simple way to parse the data above? Thanks in advance!
{nbrRows=1, rowIds=()}
I want to parse this returned data so that I can extract specific values from the object such as "nbrRows". I have already tried "JSON.deserializeUntyped" but due to the format not being typical JSON this did not work. I also tried "getPopulatedFieldsAsMap" but learn that this only works with SObjects, not an object.
Is there a simple way to parse the data above? Thanks in advance!
From the looks of it, looks like nbrRows is always an Integer and rowIds is probably a list of ID strings?
In that case you can make a wrapper class like:
Then you can cast the value as this type and get the values directly, i.e. This will try and 'force' the method to return as that type and if the data types match it should work.
If it returns a JSON string you'd be able to deserliaze it using your wrapper class too, like:
I just tried this however when I attempt to cast I get this error:
This seems like I am already getting a Map back however when I try object.get('key') I see the compile error