What is DataWeave's type system and how does type coercion work?
Suggested answer
DataWeave is a statically typed language with type inference. Core types: String, Number, Boolean, Null, Array, Object, Date, DateTime, LocalDateTime, Period, Binary, Regex, Any, Nothing. Type coercion: Explicit casting with as: "42" as Number, true as String, "2024-01-15" as Date {format: "yyyy-MM-dd"}. The as operator accepts format metadata for date/number parsing. Type checking: payload is String returns true/false. Pattern matching with match on types: payload match { case is Array -> ... case is Object -> ... }. Custom types: type EmailAddress = String {matches: /^[\\w.]+@[\\w.]+$/} — adds regex validation. Understanding DataWeave types is critical for transforming between JSON, XML, CSV, and Java object representations.
Practice content for interview preparation; not an official vendor answer. Verify details against current product documentation.
Community comments (0)
No comments yet.
Sign in or create a free account to add a comment. Comments are moderated before they appear.