Target filter
Search Kotlin docs
  • Platforms
  • Tealium Prism Kotlin
core/com.tealium.prism.core.api.data/DataItem/Companion/convert

convert

@JvmStatic
fun convert(any: Any?, default: DataItem): DataItem

Attempts to create a DataItem that contains any as its value. If the conversion to a DataItem fails for any reason, then the default value is returned instead.

Parameters

any

Value to wrap as a DataItem

default

Default value to use if conversion to DataItem fails


@JvmStatic
fun convert(any: Any?): DataItem

Attempts to create a DataItem that contains any as its value. If the conversion to a DataItem fails for any reason, then the NULL value is returned instead.

Types that require no conversion are as follows: String, Int, Long, Double, Boolean, DataList, DataObject

If any is a DataItemConvertible, then it will first be converted using DataItemConvertible.asDataItem

Float and Short are coerced to Double and Int respectively, whilst Char is also coerced to a String

Collection, JSONArray and Array types will be converted to a DataList. Any contained objects that cannot be converted to a DataItem will be omitted from the resulting DataList

Map and JSONObject types will be converted to a DataObject. Any contained objects that cannot be converted to a DataItem will be omitted from the resulting DataObject

Return

any as a DataItem if possible, else NULL

Parameters

any

Value to wrap as a DataItem

Generated by Dokka
(c) Tealium 2026