OpenEdge ABL adds additional tags on get request

Viewed 55

I have a below response json created by openedge ABL GET rest end point. Why does it adds response, ttcust and ttcust tags additionally? Is there a way to remove them while generating response json? Thank you in advance.

{
    "response": {
        "ttcust": {
            "ttcust": [
                {
                    "CustNum": 1,
                    "Country": "USA",
                    "Name": "Lift Tours",
                    "Address": "276 North Drive",
                    "Address2": "",
                    "City": "Burlington",
                    "State": "MA",
                    "PostalCode": "01730",
                    "Contact": "Gloria Shepley",
                    "Phone": "(617) 450-0086",
                    "SalesRep": "HXM",
                    "CreditLimit": 66700.0,
                    "Balance": 903.64,
                    "Terms": "Net30",
                    "Discount": 35,
                    "Comments": "This customer is on credit hold.",
                    "Fax": "",
                    "EmailAddress": ""
                },
                {
                    "CustNum": 2,
                    "Country": "Finland",
                    "Name": "Urpon Frisbee",
                    "Address": "Rattipolku 3",
                    "Address2": "",
                    "City": "Oslo",
                    "State": "Uusima",
                    "PostalCode": "45321",
                    "Contact": "Urpo Leppakoski",
                    "Phone": "(603) 532 5471",
                    "SalesRep": "DKP",
                    "CreditLimit": 27600.0,
                    "Balance": 437.63,
                    "Terms": "Net30",
                    "Discount": 35,
                    "Comments": "Ship all products 2nd Day Air.",
                    "Fax": "",
                    "EmailAddress": ""
                }

            ]
        }
    }
}
1 Answers

This somewhat depends on what request you're making. The standard Data Object Service request will return data in this format - that's going to be a GET web/CustomerSvc/Customers request , or a GET rest/CustomerSvc/Customers request.

The first path segment here - the web or the rest - will determine how much flexibility the server has. For /rest, that's what you get, no choice really.

For the Web transport (aka /web/ ) it depends on a number of factors. If you are using Data Object Services (aka "business entity" classes that are annotated) then you are likely using the Data Object Handler to process requests (you can check this if there's an entry in the PASOE instance's conf/openedge.properties file with an entry that looks something like handler1=OpenEdge.Web.DataObject.DataObjectHander:/pdo).

In this latter case you can set up an event handler that can manipulate the response - check out https://github.com/progress/Spark-Toolkit/blob/develop/docs/Data%20Object%20Handler%20Guide.docx for how to use the Invoked event handler. That is called after the data is returned from the business logic but before it is returned to the client. You can manipulate the JSON programatically and strip off whatever you want.

You can remove the envelope - the response property in the .gen or .map file can be set to 'false' or blank. If the property's value is null or doesn't exist, then no envelope will be added to the response.

Related