36 std::string_view view { key->text, key->
length };
37 return { view, (
json_t*)m_entry.value };
40 bool ObjectIterator::has_next()
const
49 std::string_view view { key->text, key->
length };
50 return { view, (
json_t*)m_entry.value };
82 return {
string->text,
string->
length };
87 mpz_init_set(integer, m_ast->
integer);
102 return { m_ast->
array };
an iterator over the values of a json array
ArrayIterator & operator++()
bool operator!=(const ArrayIterator &other) const
Json operator[](size_t index) const
get a value same as get
Json get(size_t index) const
get a value access a value from the array by index
ArrayIterator begin() const
start iterating iterate over the values of the array
size_t length() const
get the length of the array
ArrayIterator end() const
end iterating
JsonParser(arena_t *arena)
create a json parser
Json parse(io_t *io)
parse a json value parse the contents of an io object into a json value
a json value a json node from a parsed json document
CT_PUREFN bool is_object() const
check if the value is an object
constexpr CT_PUREFN bool is_valid() const
check if the value is valid this should always be checked before using any other methods
CT_PUREFN Object as_object() const
get the object value
CT_PUREFN bool is_float() const
check if the value is a float
CT_PUREFN std::string_view as_string() const
get the string value
void as_integer(mpz_t integer) const
get the integer value
CT_PUREFN bool is_null() const
check if the value is null
CT_PUREFN Array as_array() const
get the array value
CT_PUREFN bool as_bool() const
get the boolean value
Json operator[](const char *key) const
get a value from an object by key same as get(const char*)
Json get(const char *key) const
get a value from an object by key
CT_PUREFN bool is_bool() const
check if the value is a boolean
CT_PUREFN bool is_array() const
check if the value is an array
CT_PUREFN json_kind_t get_kind() const
get the kind of the value
CT_PUREFN bool is_integer() const
check if the value is an integer
CT_PUREFN bool is_string() const
check if the value is a string
CT_PUREFN float as_float() const
get the float value
CT_PUREFN size_t length() const
get the length of an array
CT_PUREFN bool is_kind(json_kind_t kind) const
check if the value is a specific kind
an iterator over the members of a json object
ObjectIterator & operator++()
member_t operator*() const
bool operator!=(const ObjectIterator &other) const
Json get(const char *key) const
get a value access a value from the object by key
Json operator[](const char *key) const
get a value same as get
ObjectIterator begin() const
start iterating iterate over the members of the object
ObjectIterator iter() const
ObjectIterator end() const
end iterating
CT_NODISCARD CT_PUREFN CT_STD_API bool map_has_next(const map_iter_t *iter)
check if a map iterator has more elements
CT_NODISCARD CT_PUREFN CT_STD_API map_iter_t map_iter(const map_t *map)
create a new map iterator
CT_NODISCARD CT_PUREFN CT_STD_API void * map_get(const map_t *map, const void *key)
get a value from a map
CT_NODISCARD CT_NOALIAS CT_STD_API map_entry_t map_next(map_iter_t *iter)
get the next key-value pair from a map iterator
json_kind_t
the kind of json value
CT_JSON_API json_t * json_map_get(const json_t *json, const char *key)
get a json value from an object by key
CT_JSON_API json_t * json_scan(io_t *io, logger_t *logger, arena_t *arena)
scan an io into a json value scan the contents of an io object into a json value
CT_NODISCARD CT_NOTIFY_API logger_t * logger_new(arena_t *arena)
create a new logger
#define CTASSERT(expr)
assert a condition, prints the condition as a message
CT_NODISCARD CT_PUREFN CT_STD_API size_t typevec_len(const typevec_t *vec)
get the length of a vector
CT_NODISCARD CT_PUREFN CT_STD_API void * typevec_offset(const typevec_t *vec, size_t index)
get a pointer to the value at the given index
a member of a json object
mpz_t integer
the integer value of this node
text_view_t string
the string value of this node
typevec_t array
the array value of this node
bool boolean
the boolean value of this node
json_kind_t kind
the kind of json value
const map_t * object
the object value of this node
float real
the float value of this node
const void * key
the key of this entry
a non-owning view of text
size_t length
the number of characters in the text