Handling an array in Rest Service

If you have questions or if you want to share your opinion about Aware IM post your message on this forum
Post Reply
Frank2
Posts: 21
Joined: Tue Nov 17, 2020 10:33 pm

Handling an array in Rest Service

Post by Frank2 »

Hi,

I am working with a Parent Object as the return object in a very straight forward GET Restful Service.
This Parent object contains an attribute of type String array with the name DataClasses.
This is what the JSON response should look like:
Sample3.PNG
Sample3.PNG (5.22 KiB) Viewed 757 times
I have created the attribute DataClasses in the Parent Object and it points to the Child Object with a single String parameter of type Text.
See links below:
Parent Object
Parent Object
Sample1.PNG (5.32 KiB) Viewed 757 times
Child Object
Child Object
Sample2.PNG (3.84 KiB) Viewed 757 times
I usually use it this way when I have an array of Objects stored in the DataClasses attribute where the object has its own attributes and the REST knows where to write the values to based on the same attribute name, but in the case there is no name and only the the string values:
"Email addresses",
"Geographic locations",
"IP addresses",
The problem is it does not return any value to the DataClasses object and I sit with an empty table in my DB. The Service works fine for the Parent Object but not for the child object with the String array.

Please help
Thanks
Francois
Jaymer
Posts: 2430
Joined: Tue Jan 13, 2015 10:58 am
Location: Tampa, FL
Contact:

Re: Handling an array in Rest Service

Post by Jaymer »

After reading this several times, I think I know what you’re saying. Not 100% certain. it would help to see an actual reply you are getting from the service.
It seems like you’ve done this before, but on this particular type of reply there isn’t the normal named pairs/elements or whatever the correct term is. I may not even be valid JSON In that reply.
I’m not sure what the volume is, or if speed is an issue, but you may need to just parse this yourself if it doesn’t conform to what aware is expecting.
I think anyone will be able to help more once we see a full reply posted here.
Click Here to see a collection of my tips & hacks on this forum. Or search for "JaymerTip" in the search bar at the top.

Jaymer
Aware Programming & Consulting - Tampa FL
Frank2
Posts: 21
Joined: Tue Nov 17, 2020 10:33 pm

Re: Handling an array in Rest Service

Post by Frank2 »

Hi thank you Jaymer, I figured it out.
I declared DataClasses as a primitive string value which gives me the return in the following format: string1^string2^string3 instead of creating an attribute DataClasses that points to an array of Objects.

Thank you for your reply.

Kind regards,
Francois
Post Reply