All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.alibaba.fastjson2.JSONArray.kt Maven / Gradle / Ivy

The newest version!
@file:Suppress(
    "HasPlatformType"
)

package com.alibaba.fastjson2

/**
 * E.g.
 * ```
 *   val data = "...".parseArray()
 *   val users = data.to()
 * ```
 *
 * @return [T]?
 * @since 2.0.3
 */
inline fun  JSONArray.to() =
    to(T::class.java)

/**
 * Implemented using [TypeReference]
 *
 * E.g.
 * ```
 *   val data = "...".parseArray()
 *   val users = data.into>()
 * ```
 *
 * @return [T]?
 * @since 2.0.3
 */
inline fun  JSONArray.into() =
    to(reference().getType())

/**
 * E.g.
 * ```
 *   val data = "...".parseArray()
 *   val users = data.to(6)
 * ```
 *
 * @return [T]?
 * @since 2.0.4
 */
inline fun  JSONArray.to(
    index: Int,
    vararg features: JSONReader.Feature
) = getObject(
    index, T::class.java, *features
)

/**
 * Implemented using [TypeReference]
 *
 * E.g.
 * ```
 *   val data = "...".parseArray()
 *   val users = data.into>(6)
 * ```
 *
 * @return [T]?
 * @since 2.0.4
 */
inline fun  JSONArray.into(
    index: Int,
    vararg features: JSONReader.Feature
) = getObject(
    index, reference().getType(), *features
)

/**
 * E.g.
 * ```
 *   val data = "...".parseArray()
 *   val user = data.toList()
 * ```
 *
 * @return [T]?
 * @since 2.0.3
 */
inline fun  JSONArray.toList(
    vararg features: JSONReader.Feature
) = toList(
    T::class.java, *features
)




© 2015 - 2024 Weber Informatics LLC | Privacy Policy