Function query

  • URL query decoder.

    typia.http.query() is a function decoding a query string or an URLSearchParams instance, with automatic type casting to the expected type. When property type be defined as boolean or number type, typia.http.query() will cast the value to the expected type when decoding.

    By the way, as URL query is not enough to express complex data structures, typia.http.query() function has some limitations. If target type T is not following those restrictions, compilation errors would be occured.

    1. Type T must be an object type
    2. Do not allow dynamic property
    3. Only boolean, bigint, number, string or their array types are allowed
    4. By the way, union type never be not allowed

    Also, typia.http.query() function does not perform validation about the decoded value. Therefore, if you can't sure that input data is following the T type, it would better to call one of below functions intead.

    Type Parameters

    • T extends object

      Expected type of decoded value

    Parameters

    • input: string | URLSearchParams

      Query string or URLSearchParams instance

    Returns Resolved<T>

    Decoded query object

    Jeongho Nam - https://github.com/samchon