Skip to main content
Graeme Steyn 님이 #MuleSoft DataWeave에 질문했습니다

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.

답변 2개
  1. 2019년 11월 26일 오전 9:34

    @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

    @Graeme Steyn​ Stack of JSON objects above is New Line Delimited JSON. See here http://ndjson.org/Dataweave 2.

    Check deatils about Dataeweave support for NdJON here https://docs.mulesoft.com/mule-runtime/4.2/dataweave-formats#format_ndjson

     

    HTH

    -Rahul

0/9000