Function get_type

Synopsis

#include <include/sajson.h>

type get_type() const

Description

Returns the JSON value's type.

Mentioned in

Source

Lines 462-486 in include/sajson.h.

type get_type() const {
    // As of 2020, current versions of MSVC generate a jump table for this
    // conversion. If it matters, a more clever mapping with knowledge of
    // the specific values is possible. gcc and clang generate good code --
    // at worst a table lookup.
    switch (value_tag) {
    case tag::integer:
        return TYPE_INTEGER;
    case tag::double_:
        return TYPE_DOUBLE;
    case tag::null:
        return TYPE_NULL;
    case tag::false_:
        return TYPE_FALSE;
    case tag::true_:
        return TYPE_TRUE;
    case tag::string:
        return TYPE_STRING;
    case tag::array:
        return TYPE_ARRAY;
    case tag::object:
        return TYPE_OBJECT;
    }
    SAJSON_UNREACHABLE();
}





Add Discussion as Guest

Log in