You can translate the question and the replies:

Exposing JSON data into API with specific parameter

I have this format as of now when I exposed my data into JSON format(the default one): ``` { "name": "cp", "elements": [ { "reference": "beta5", "ordernumber_0": 8008, "product": "gaiytaqw", "what": "sagar", "application": "user123459", "datetime": "2021-05-09T10:58:51.000Z", "timestamp": "2021-05-10T10:58:51Z" } ], "links": [ { "rel": "self", "href": "http://localhost:9090/server/admin/cp/views/cp?$format=json" } ] } ``` I want a different set of structure like this: ``` { "WebsiteData": { "Data":{ "Topic":{ "what": "sagar", "applicationnam": "user 3459", "datetime": "2021-05-09T10:58:51.000Z", "timestamp": "2021-05-10T10:58:51Z", "Topic2": { "applicationnam": "user ", "datetime": "2021-05-09T10:58:51.000Z", "timestamp": "2021-05-10T10:58:51Z" } }, "links": [ { "rel": "self", "href": "http://localhost:9090/server/admin/cp/views/cp?$format=json" }} ``` 1. How can I set the format like this, kindly see mainly: Websitedata, data, Topic and Topic2 2. the source is JSON and output API will be JSON : I dont think XSLT will work? ******************************************************************************************EDIT : I am able to generate this structure till now: My Topic2 has came into single column using NEST function and Gruop by on (applicationnam,datetime,timestamp,what) "Topic2": { "applicationnam": "user ", "datetime": "2021-05-09T10:58:51.000Z", "timestamp": "2021-05-10T10:58:51Z" } }, "links": [ { "rel": "self", "href": "http://localhost:9090/server/admin/cp/views/cp?$format=json" }}
12-05-2021 07:12:07 -0400

5 Answers

Hi, The easiest way to expose JSON in a specific format with Denodo would be to construct the desired structure as a single view, that I can then expose through the API. I can do this by creating a new view, making use of Denodo’s [Compound DataTypes]( ), Array and Register, to build out the shape of my return, and loading values from my existing data into it. Refer to the [Processing Compound Types : Example]( given in the Virtual DataPort VQL Guide for a concrete example of how this sort of structure could be built up. As well as the [Defining DataTypes]( section of the VQL Guide for specific definition of these types. Hope this helps!
Denodo Team
13-05-2021 17:05:41 -0400
But still after adding the required format. The moment I expose that into APi it will again give "Element" object ``` { "name": "cp", "elements": [ { ``` I just want to rename this "elements" as "data". I have already done other things with Register and NEST
16-05-2021 10:15:29 -0400
any response on this question?
24-05-2021 22:38:54 -0400
The name shows the value of unified view in it.? Can we modiy this value of name to something else without changing in unified view?
24-05-2021 22:44:45 -0400
Hi, Denodo’s Restful Web Service uses the ‘Elements’ key to store the values of all tuples returned from the View. This key should appear in all the returned information from the Restful WebService, following the Key-value indicating the name of the view, and the Key-value indicating the description, if any. These keys will be present in any response from the Restful WebService. If I am getting my returns within Elements in the expected structure, and just need to rename the key containing my list of values, the easiest thing to do would be to programmatically rename the key after returning it (for example, using Javascript or PHP), as I can be sure it will be named “elements” and appear in the first group of keys in the returned JSON. If programmatically renaming keys in the return as a second step is not an option, then it is likely that another tool would be more appropriate for this application. For specifics on how the JSON return is constructed, refer to the [JSON Representation]( Section of the Virtual DataPort Administration Guide. Hope this helps!
Denodo Team
25-05-2021 15:01:46 -0400
You must sign in to add an answer. If you do not have an account, you can register here