I’m using webMethods 10.4. I have a service in which I’m trying to convert a pipe-delimited flat file to a file containing JSON, where each row in my flat file would become one element in my outputted JSON. I don’t know if I’m going about it correctly, though. In my service, I have tehse steps
pub.file.getFile
SEQUENCE
MAP
pub.flatFile.convertToValues
pub.json:documentToJSONString
I have created a schema and document type representing rows in my flat file. However, when I output my JSON, I get entries like
{“recordWithNoID”:{“@record-id”:“recordWithNoID”,“@delimiters”:{“record”:“\n”,“field”:“|”,“subfield”:“”,“FormatInfo”:{}},“@segment-id”:“recordWithNoID”,“RecordType”:“A-123”,“SubmissionDate”:“11/23/2018” …
The entries “RecordType” and “SubmissionDate” are from my data dictionary, however, the first part of the JSON that has stuff like “recordWithNoID” and “@delimiters” seems like meta data from the dictionary. Is there any way I can exclude that information when converting to JSON? I would like to include only the data pertaining to the fields.
I have attached a screen shot showing the pipeline between pub.flatFIle:convertToValues and pub.json:documentToJSONString.
Hi Dave,
After the convertToValues step, we can add one more Map flow step to map the output flatfile IS document to another IS document structure (which has list of fields required for output JSON ) and then you can convert the document to JSON using documentToJSON service. so that there wont be any unwanted flatfile schema metadata related fields.
Thanks
Arul
HI Arul,
When you say
Map flow step to map the output flatfile IS document to another IS document structure
How would I structure this second IS document so that the metadata fields are gone? I created the first IS document by selecting my schema record and clicking the “Create Document Type” button along the top tool bar.
First IS document is mainly to store the values which are parsed from flat file. you have done this part already.
As this is array of records from flat file output, better loop over the flat file record and map the first IS document to map it to second IS document (this could be some temporary IS document in the pipeline as well) with few fields which are required from first IS document.
After that second IS document, convert it to JSON using documentToJSON
Hi Dave,
It should be like the below screenshot.
Thanks,
Arul