[resolved] HOW: JSON output, multiple records as single JSON object?

One Star

[resolved] HOW: JSON output, multiple records as single JSON object?

Hi there. I have a tRESTRequest triggering a tRESTClient accessing a REST/POX service. This output is put through a tExtractXMLField to get the relevant information from a complex structured XML response. So far so good, the tLogRow illustrates 13 records retrieved from the XML. Now I want to output a tRESTResponse consisting of all the records in JSON, contained as an array of objects in one containing object. What I get is 13 JSON objects, there appears to be no equivalent of the "All in one" option on the tXMLMap component, which I've used to get valid XML output, unfortunately I want JSON (I might use this later to allow POX output).
While I'm asking, once I make the job work in an ESB sense, how to I deploy it to a server, and how do I setup a server to deploy it to?

Accepted Solutions
Employee

Re: [resolved] HOW: JSON output, multiple records as single JSON object?

Hi
Linking tXMLMap output directly to tRESTResponse will do the auto conversion of XML to JSON, assuming the current response Content-Type is application/json.
The problem we have so far with this auto-conversion is that we can control some aspects of JSON serialization. For example, we can not have JSON produced as "". But we can configure it to drop the root elements which may produce the expected output, there's a drop root element JSON property is available
Can you please experiment with tXMLMap ?
Cheers, Sergey

All Replies
Employee

Re: [resolved] HOW: JSON output, multiple records as single JSON object?

Hi
Linking tXMLMap output directly to tRESTResponse will do the auto conversion of XML to JSON, assuming the current response Content-Type is application/json.
The problem we have so far with this auto-conversion is that we can control some aspects of JSON serialization. For example, we can not have JSON produced as "". But we can configure it to drop the root elements which may produce the expected output, there's a drop root element JSON property is available
Can you please experiment with tXMLMap ?
Cheers, Sergey
One Star

Re: [resolved] HOW: JSON output, multiple records as single JSON object?

Hi
Linking tXMLMap output directly to tRESTResponse will do the auto conversion of XML to JSON, assuming the current response Content-Type is application/json.
The problem we have so far with this auto-conversion is that we can control some aspects of JSON serialization. For example, we can not have JSON produced as "". But we can configure it to drop the root elements which may produce the expected output, there's a drop root element JSON property is available
Can you please experiment with tXMLMap ?
Cheers, Sergey

Thanks, that worked, of sorts. Still insists that the looped elements are an array of anonymous objects, but it suits the purpose.