Monado OpenXR Runtime
Functions
u_json.c File Reference

Tiny JSON wrapper around cJSON. More...

#include "u_json.h"
#include <assert.h>
#include "cjson/cJSON.c"
Include dependency graph for u_json.c:

Functions

bool u_json_get_string_into_array (const cJSON *json, char *out_str, size_t max_size)
 Parse a string from a JSON object into a char array. More...
 
bool u_json_get_int (const cJSON *json, int *out_int)
 Parse an int from a JSON object. More...
 
bool u_json_get_double (const cJSON *json, double *out_double)
 Parse a double from a JSON object. More...
 
bool u_json_get_float (const cJSON *json, float *out_float)
 Parse a float from a JSON object. More...
 
bool u_json_get_vec3 (const cJSON *json, struct xrt_vec3 *out_vec3)
 Parse a vec3 from a JSON object. More...
 
bool u_json_get_quat (const cJSON *json, struct xrt_quat *out_quat)
 Parse a quaternion from a JSON object. More...
 
size_t u_json_get_float_array (const cJSON *json_array, float *out_array, size_t max_size)
 Parse up to max_size floats from a JSON array. More...
 
size_t u_json_get_double_array (const cJSON *json_array, double *out_array, size_t max_size)
 Parse up to max_size doubles from a JSON array. More...
 

Detailed Description

Tiny JSON wrapper around cJSON.

Author
Jakob Bornecrantz jakob.nosp@m.@col.nosp@m.labor.nosp@m.a.co.nosp@m.m
Ryan Pavlik ryan..nosp@m.pavl.nosp@m.ik@co.nosp@m.llab.nosp@m.ora.c.nosp@m.om

Function Documentation

◆ u_json_get_double()

bool u_json_get_double ( const cJSON *  json,
double *  out_double 
)

Parse a double from a JSON object.

Returns
true if successful, false if not.

Referenced by u_json_get_double_array(), and u_json_get_float().

◆ u_json_get_double_array()

size_t u_json_get_double_array ( const cJSON *  json_array,
double *  out_array,
size_t  max_size 
)

Parse up to max_size doubles from a JSON array.

Returns
the number of elements set.

References u_json_get_double().

◆ u_json_get_float()

bool u_json_get_float ( const cJSON *  json,
float *  out_float 
)

Parse a float from a JSON object.

Returns
true if successful, false if not.

References u_json_get_double().

Referenced by u_json_get_float_array(), u_json_get_quat(), and u_json_get_vec3().

◆ u_json_get_float_array()

size_t u_json_get_float_array ( const cJSON *  json_array,
float *  out_array,
size_t  max_size 
)

Parse up to max_size floats from a JSON array.

Returns
the number of elements set.

References u_json_get_float().

◆ u_json_get_int()

bool u_json_get_int ( const cJSON *  json,
int *  out_int 
)

Parse an int from a JSON object.

Returns
true if successful, false if not.

◆ u_json_get_quat()

bool u_json_get_quat ( const cJSON *  json,
struct xrt_quat out_quat 
)

Parse a quaternion from a JSON object.

Returns
true if successful, false if not.

References u_json_get_float().

◆ u_json_get_string_into_array()

bool u_json_get_string_into_array ( const cJSON *  json,
char *  out,
size_t  max_size 
)

Parse a string from a JSON object into a char array.

Returns
true if successful, false if string does not fit in array or any other error.

◆ u_json_get_vec3()

bool u_json_get_vec3 ( const cJSON *  json,
struct xrt_vec3 out_vec3 
)

Parse a vec3 from a JSON object.

Returns
true if successful, false if not.

References u_json_get_float().