JSON data retrieved from the Analytics Event API is an array of JSON objects, e.g.
[
{ "field1": "value1", "field2": "value2"},
{ "field1": "value1", "field2": "value2"}
]
I would like to transform this to a stack of objects for submission to Splunk's HTTP Event Collector (https://docs.splunk.com/Documentation/Splunk/8.0.0/Data/FormateventsforHTTPEventCollector#Examples) - not a JSON array.
{ "field1": "value1", "field2": "value2"}
{ "field1": "value1", "field2": "value2"}
Any ideas would be greatly appreciated.
@Graeme Steyn
Stack of JSON objects above is New Line Delimited JSON. See here http://ndjson.org/
Dataweave 2.0 came with a lot of improvements and luckily for us it provides means to transform to and from NDJSON.
The above input can be directly transformed to NdJson by simply changing the mimetype in Dataweave.
%dw 2.0
output application/x-ndjson
---
payload
Check deatils about Dataeweave support for NdJON here https://docs.mulesoft.com/mule-runtime/4.2/dataweave-formats#format_ndjson
HTH
-Rahul