Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %dw 2.0
- output application/dw
- var cle = readUrl("classpath://examples/flightsAllAirlinesCLE.json", "application/json")
- fun shortform(list: Array) = list map {
- id: $.flightCode,
- when: $.departureDate,
- where: $.destination
- }
- fun normalizeDate (d: String) = d match {
- case amer if (d matches /[A-Z][a-z]{2}.*/) ->
- d as Date {format: "MMM dd, yyyy"}
- case science if (d matches /\d{4}\/\w{2}\/\w{2}/) ->
- d as Date {format: "yyyy/MM/dd"}
- else -> d as Date
- }
- ---
- shortform(cle.flights) map (f) -> (f - "when") ++
- {when: normalizeDate(f.when)}
Advertisement
Add Comment
Please, Sign In to add comment