Welcome to the SRP Forum! Please refer to the SRP Forum FAQ post if you have any questions regarding how the forum works.

Help with getting correct formatting

I have this 'playing with' code:
API APITesting.GET objResource1 = HTTP_Resource_Services('GetObject') objResource2 = HTTP_Resource_Services('GetObject') If Error_Services('NoError') then HTTP_Resource_Services('AddSubProperty', objResource1, 'x', 'address', 'PO Box 1234') HTTP_Resource_Services('AddSubProperty', objResource1, 'x', 'city', 'New Orleans') HTTP_Resource_Services('AddSubProperty', objResource1, 'x', 'county', 'Orleans') HTTP_Resource_Services('AddSubProperty', objResource1, 'x', 'state', 'LA') HTTP_Resource_Services('AddSubProperty', objResource1, 'x', 'zip', '70116') ID = "45" SelfRelURL = ParentURL : '/job/' : ID HTTP_Resource_Services('AddLinkRelations', objResource1, 'self', SelfRelURL) HTTP_Resource_Services('AddSubProperty', objResource1, 'y', 'address', 'PO Box 1234') HTTP_Resource_Services('AddSubProperty', objResource1, 'y', 'city', 'New Orleans') HTTP_Resource_Services('AddSubProperty', objResource1, 'y', 'county', 'Orleans') HTTP_Resource_Services('AddSubProperty', objResource1, 'y', 'state', 'LA') HTTP_Resource_Services('AddSubProperty', objResource1, 'y', 'zip', '70116') ID = "46" SelfRelURL = ParentURL : '/job/' : ID HTTP_Resource_Services('AddLinkRelations', objResource1, 'self', SelfRelURL) // Add _links sub-properties for HAL implementation. Rels = 'self' : @FM : 'apiEntryPoint' URLs = FullEndpointURL : @FM : FullEndpointURLNoQuery HTTP_Resource_Services('AddSubProperty', objResource2, 'Other Jobs', 'count', '4') HTTP_Resource_Services('AddEmbeddedResources', objResource2, 'Other Jobs', objResource1) HTTP_Resource_Services('AddLinkRelations', objResource2, Rels, URLs) // Serialize the JSON object. jsonResource = HTTP_Resource_Services('GetSerializedResource', objResource2) HTTP_Services('SetResponseBody', jsonResource, False$, 'application/hal+json') body =http_services("GetResponseBody") end end api

which produces this output
{ "Other Jobs": { "count": "4" }, "_embedded": { "Other Jobs": [ { "x": { "address": "PO Box 1234", "city": "New Orleans", "county": "Orleans", "state": "LA", "zip": "70116" }, "_links": { "self": { "href": "http://localhost/api/job/46" } }, "y": { "address": "PO Box 1234", "city": "New Orleans", "county": "Orleans", "state": "LA", "zip": "70116" } } ] }, "_links": { "self": { "href": "http://localhost/api/apitesting/jobs" }, "apiEntryPoint": { "href": "http://localhost/api/apitesting" } } }

BUT, I want it to look like this.
The final api will be extracting the data from data files and NOT using the http_resource_service to format from tables.
This is just data pulled from help pages. I know the formatting braces are out, but you get the gist.
"_embedded": { "Other Jobs": "count": "2" [ { { { "address": "PO Box 1234", "city": "New Orleans", "county": "Orleans", "state": "LA", "zip": "70116" }, "_links": { "self": { "href": "http://localhost/api/job/46" } }, { "address": "PO Box 1234", "city": "New Orleans", "county": "Orleans", "state": "LA", "zip": "70116" "_links": { "self": { "href": "http://localhost/api/job/47" } } } ] }, "_links": { "self": { "href": "http://localhost/api/apitesting/jobs" }, "apiEntryPoint": { "href": "http://localhost/api/apitesting" } } }

Sign In or Register to comment.