0
votes

I'm trying convert to csv to json format using mule datamapper ,it is working fine.

below output it produce

[ {

  "propertyState" : "AL",
  "propertyCity" : "NJ",
  "propertyZipCode" : "67890",
  "propertyCounty" : "US"

} ]

But want to remove [ ] this from json format. using datamapper is it possible

mule modify json output datamapper

1
These brackets mean a list of lines of that csv; you will need them if it has more lines. Why do you want to remove them?Uwe Allner
In mule I want json format output without these [ ] because ,i need to pass this as input to external systemmuledevlepoer07
When you defined the mapping for the json output, did you select List<Element>? If you want to output just one element, you can just select Element. HTHclare

1 Answers

0
votes

[] defines List for the elements .. That is required if your elements are repeating and a Valid JSON format ..

If you don't want the [] to be there then the work around will be use <json:json-to-object-transformer returnClass="java.util.List" doc:name="JSON to List" /> to extract each elements value from the JSON payload and create your payload using expression ..

But again this is not a recommended approach since you always require [] in your JSON as you will be getting multiple rows from CSV file and the JSON format should have [] since that will represent it as List which is a valid format