e-json-utils

e-json-utils — A set of JSON utility functions

Functions

Includes

#include <libedataserver/libedataserver.h>

Description

Functions

e_json_get_array_member ()

JsonArray *
e_json_get_array_member (JsonObject *object,
                         const gchar *member_name);

Returns the member_name of the object as a JsonArray, checking the type is as expected. Asking for an array when the member holds a different type is considered a programmer error.

[skip]

Parameters

object

a JsonObject object

 

member_name

name of the member

 

Returns

the member_name of the object as a JsonArray, or NULL when the member cannot be found or when it is a JSON-NULL object.

[transfer none][nullable]

Since: 3.46


e_json_begin_array_member ()

void
e_json_begin_array_member (JsonBuilder *builder,
                           const gchar *member_name);

Begins a new array object, optionally named member_name . The member_name can be NULL or an empty string, in which case the new array has no name (unless the builder has already set the member name).

End the array object with e_json_end_array_member().

[skip]

Parameters

builder

a JsonBuilder

 

member_name

name of the array.

[nullable]

Since: 3.46


e_json_end_array_member ()

void
e_json_end_array_member (JsonBuilder *builder);

Ends the array object begun with e_json_begin_array_member().

[skip]

Parameters

builder

a JsonBuilder

 

Since: 3.46


e_json_get_boolean_member ()

gboolean
e_json_get_boolean_member (JsonObject *object,
                           const gchar *member_name,
                           gboolean default_value);

Returns the member_name of the object as a gboolean, checking the type is as expected. Asking for a gboolean when the member holds a different type is considered a programmer error.

[skip]

Parameters

object

a JsonObject object

 

member_name

name of the member

 

default_value

the default value to return

 

Returns

the member_name of the object as a gboolean, or the default_value when the member cannot be found or when it is a JSON-NULL object.

Since: 3.46


e_json_add_boolean_member ()

void
e_json_add_boolean_member (JsonBuilder *builder,
                           const gchar *member_name,
                           gboolean value);

Adds a boolean member named member_name , holding the value . The member_name cannot be NULL nor an empty string.

[skip]

Parameters

builder

a JsonBuilder

 

member_name

member name.

[not nullable]

value

value to set

 

Since: 3.46


e_json_get_double_member ()

gdouble
e_json_get_double_member (JsonObject *object,
                          const gchar *member_name,
                          gdouble default_value);

Returns the member_name of the object as a gdouble, checking the type is as expected. Asking for a gdouble when the member holds a different type is considered a programmer error.

[skip]

Parameters

object

a JsonObject object

 

member_name

name of the member

 

default_value

the default value to return

 

Returns

the member_name of the object as a gdouble, or the default_value when the member cannot be found or when it is a JSON-NULL object.

Since: 3.46


e_json_add_double_member ()

void
e_json_add_double_member (JsonBuilder *builder,
                          const gchar *member_name,
                          gdouble value);

Adds a double member named member_name , holding the value . The member_name cannot be NULL nor an empty string.

[skip]

Parameters

builder

a JsonBuilder

 

member_name

member name.

[not nullable]

value

value to set

 

Since: 3.46


e_json_get_int_member ()

gint64
e_json_get_int_member (JsonObject *object,
                       const gchar *member_name,
                       gint64 default_value);

Returns the member_name of the object as a gint64, checking the type is as expected. Asking for a gint64 when the member holds a different type is considered a programmer error.

[skip]

Parameters

object

a JsonObject object

 

member_name

name of the member

 

default_value

the default value to return

 

Returns

the member_name of the object as a gint64, or the default_value when the member cannot be found or when it is a JSON-NULL object.

Since: 3.46


e_json_add_int_member ()

void
e_json_add_int_member (JsonBuilder *builder,
                       const gchar *member_name,
                       gint64 value);

Adds an integer member named member_name , holding the value . The member_name cannot be NULL nor an empty string.

[skip]

Parameters

builder

a JsonBuilder

 

member_name

member name.

[not nullable]

value

value to set

 

Since: 3.46


e_json_get_null_member ()

gboolean
e_json_get_null_member (JsonObject *object,
                        const gchar *member_name,
                        gboolean default_value);

Returns whether the member_name of the object is a JSON-NULL object, or the default_value , when the member_name does not exist.

[skip]

Parameters

object

a JsonObject object

 

member_name

name of the member

 

default_value

the default value to return

 

Returns

whether the member_name of the object is a JSON-NULL object, or the default_value when the member cannot be found.

Since: 3.46


e_json_add_null_member ()

void
e_json_add_null_member (JsonBuilder *builder,
                        const gchar *member_name);

Adds a JSON-NULL member named member_name . The member_name cannot be NULL nor an empty string.

[skip]

Parameters

builder

a JsonBuilder

 

member_name

member name.

[not nullable]

Since: 3.46


e_json_get_object_member ()

JsonObject *
e_json_get_object_member (JsonObject *object,
                          const gchar *member_name);

Returns the member_name of the object as a JsonObject, checking the type is as expected. Asking for an object when the member holds a different type is considered a programmer error.

[skip]

Parameters

object

a JsonObject object

 

member_name

name of the member

 

Returns

the member_name of the object as a JsonObject, or NULL when the member cannot be found or when it is a JSON-NULL object.

[transfer none][nullable]

Since: 3.46


e_json_begin_object_member ()

void
e_json_begin_object_member (JsonBuilder *builder,
                            const gchar *member_name);

Begins a new object, optionally named member_name . The member_name can be NULL or an empty string, in which case the new object has no name (unless the builder has already set the member name).

End the object with e_json_end_object_member().

[skip]

Parameters

builder

a JsonBuilder

 

member_name

name of the object.

[nullable]

Since: 3.46


e_json_end_object_member ()

void
e_json_end_object_member (JsonBuilder *builder);

Ends the object begun with e_json_begin_object_member().

[skip]

Parameters

builder

a JsonBuilder

 

Since: 3.46


e_json_get_string_member ()

const gchar *
e_json_get_string_member (JsonObject *object,
                          const gchar *member_name,
                          const gchar *default_value);

Returns the member_name of the object as a string, checking the type is as expected. Asking for a string when the member holds a different type is considered a programmer error.

[skip]

Parameters

object

a JsonObject object

 

member_name

name of the member

 

default_value

the default value to return.

[nullable]

Returns

the member_name of the object as string, or the default_value when the member cannot be found or when it is a JSON-NULL object.

[transfer none][nullable]

Since: 3.46


e_json_add_string_member ()

void
e_json_add_string_member (JsonBuilder *builder,
                          const gchar *member_name,
                          const gchar *value);

Adds a string member named member_name , holding the value . The member_name cannot be NULL nor an empty string. When the value is NULL, an empty string is set instead.

See e_json_add_nonempty_string_member(), e_json_add_nonempty_or_null_string_member().

[skip]

Parameters

builder

a JsonBuilder

 

member_name

member name.

[not nullable]

value

value to set.

[nullable]

Since: 3.46


e_json_add_nonempty_string_member ()

void
e_json_add_nonempty_string_member (JsonBuilder *builder,
                                   const gchar *member_name,
                                   const gchar *value);

Adds a string member named member_name , holding the value , but only if the value is a non-empty string. The member_name cannot be NULL nor an empty string.

See e_json_add_string_member(), e_json_add_nonempty_or_null_string_member().

[skip]

Parameters

builder

a JsonBuilder

 

member_name

member name.

[not nullable]

value

value to set.

[nullable]

Since: 3.46


e_json_add_nonempty_or_null_string_member ()

void
e_json_add_nonempty_or_null_string_member
                               (JsonBuilder *builder,
                                const gchar *member_name,
                                const gchar *value);

Adds a string member named member_name , holding the value , if the value is a non-empty string, otherwise adds a JSON-NULL object.

The member_name cannot be NULL nor an empty string.

See e_json_add_string_member(), e_json_add_nonempty_string_member().

[skip]

Parameters

builder

a JsonBuilder

 

member_name

member name.

[not nullable]

value

value to set.

[nullable]

Since: 3.46


e_json_get_date_member ()

gint64
e_json_get_date_member (JsonObject *object,
                        const gchar *member_name,
                        gint64 default_value);

Returns the member_name date (encoded as YYYY-MM-DD) of the object as a gint64 Unix time. The member itself is expected to be of type string.

[skip]

Parameters

object

a JsonObject object

 

member_name

name of the member

 

default_value

the default value to return

 

Returns

the member_name date (encoded as YYYY-MM-DD) of the object as a gint64 Unix time, or the default_value when the member cannot be found or when it is a JSON-NULL object.

Since: 3.46


e_json_add_date_member ()

void
e_json_add_date_member (JsonBuilder *builder,
                        const gchar *member_name,
                        gint64 value);

Adds a date (encoded as YYYY-MM-DD) member named member_name , holding the date as Unix time in the value , stored as string. The member_name cannot be NULL nor an empty string.

[skip]

Parameters

builder

a JsonBuilder

 

member_name

member name.

[not nullable]

value

value to set, as Unix time

 

Since: 3.46


e_json_get_iso8601_member ()

gint64
e_json_get_iso8601_member (JsonObject *object,
                           const gchar *member_name,
                           gint64 default_value);

Returns the member_name ISO 8601 date/time of the object as a gint64 Unix time. The member itself is expected to be of type string.

[skip]

Parameters

object

a JsonObject object

 

member_name

name of the member

 

default_value

the default value to return

 

Returns

the member_name ISO 8601 date/time of the object as a gint64 Unix time, or the default_value when the member cannot be found or when it is a JSON-NULL object.

Since: 3.46


e_json_add_iso8601_member ()

void
e_json_add_iso8601_member (JsonBuilder *builder,
                           const gchar *member_name,
                           gint64 value);

Adds a date/time (encoded as ISO 8601) member named member_name , holding the Unix time in the value , stored as string. The member_name cannot be NULL nor an empty string.

[skip]

Parameters

builder

a JsonBuilder

 

member_name

member name.

[not nullable]

value

value to set, as Unix time

 

Since: 3.46


e_json_util_decode_date ()

gint64
e_json_util_decode_date (const gchar *str_date,
                         gint64 default_value);

Returns the str_date (encoded as YYYY-MM-DD) as a gint64 Unix time.

[skip]

Parameters

str_date

date as string.

[nullable]

default_value

the default value to return

 

Returns

the str_date (encoded as YYYY-MM-DD) as a gint64 Unix time, or the default_value when the str_date cannot be decoded.

Since: 3.46


e_json_util_encode_date ()

gchar *
e_json_util_encode_date (gint64 value);

Encodes (as YYYY-MM-DD) the date value Unix time to string.

[skip]

Parameters

value

date to encode, as Unix time

 

Returns

Unix time value encoded as date.

[transfer full]

Since: 3.46


e_json_util_decode_iso8601 ()

gint64
e_json_util_decode_iso8601 (const gchar *str_datetime,
                            gint64 default_value);

e_json_util_encode_iso8601 ()

gchar *
e_json_util_encode_iso8601 (gint64 value);

Encodes (as ISO 8601) the date/time value Unix time to string.

[skip]

Parameters

value

date/time to encode, as Unix time

 

Returns

Unix time value encoded as date/time.

[transfer full]

Since: 3.46