All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Typedefs | Functions
json.h File Reference
#include "config.h"
#include "json_missing.h"
#include <freeradius-devel/radiusd.h>
+ Include dependency graph for json.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

typedef struct fr_jpath_node fr_jpath_node_t
 

Functions

char * fr_jpath_asprint (TALLOC_CTX *ctx, fr_jpath_node_t const *head)
 Print a node list to a string for debugging. More...
 
size_t fr_jpath_escape_func (UNUSED REQUEST *request, char *out, size_t outlen, char const *in, UNUSED void *arg)
 Escapes special chars. More...
 
int fr_jpath_evaluate_leaf (TALLOC_CTX *ctx, value_data_t **out, PW_TYPE dst_type, fr_dict_attr_t const *dst_enumv, json_object *root, fr_jpath_node_t const *jpath)
 Evaluate a parsed jpath expression against a json-c tree. More...
 
ssize_t fr_jpath_parse (TALLOC_CTX *ctx, fr_jpath_node_t **head, char const *in, size_t inlen)
 Parse a jpath string. More...
 
size_t fr_json_from_pair (char *out, size_t outlen, VALUE_PAIR const *vp)
 Prints attribute as string, escaped suitably for use as JSON string. More...
 
int fr_json_object_to_value_data (TALLOC_CTX *ctx, value_data_t *out, json_object *object, PW_TYPE dst_type, fr_dict_attr_t const *dst_enumv)
 Convert json object to value_data_t. More...
 
void fr_json_version_print (void)
 Print JSON-C version. More...
 

Typedef Documentation

Definition at line 47 of file json.h.

Function Documentation

char* fr_jpath_asprint ( TALLOC_CTX *  ctx,
fr_jpath_node_t const *  head 
)

Print a node list to a string for debugging.

Will not be identical to the original parsed string, but should be sufficient for testing purposes.

Parameters
ctxto allocate string in.
headof the node list.
Returns
the string representation of the node list.

Definition at line 411 of file jpath.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

size_t fr_jpath_escape_func ( UNUSED REQUEST request,
char *  out,
size_t  outlen,
char const *  in,
UNUSED void *  arg 
)

Escapes special chars.

Escapes any characters that may have special meaning within a jpath expression

Parameters
requestCurrent request (unused may be NULL).
outWhere to write the escaped string.
outlenLength of the output buffer.
indata to escape.
arguctx data, not used.
Returns
the number of chars written to out.

Definition at line 110 of file jpath.c.

+ Here is the caller graph for this function:

int fr_jpath_evaluate_leaf ( TALLOC_CTX *  ctx,
value_data_t **  out,
PW_TYPE  dst_type,
fr_dict_attr_t const *  dst_enumv,
json_object *  root,
fr_jpath_node_t const *  jpath 
)

Evaluate a parsed jpath expression against a json-c tree.

Will produce one or more value_data_t structures of the desired type, or error out if the conversion between types fails.

Parameters
[in,out]ctxto allocate value_data_t in.
[out]outWhere to write value_data_t.
[in]dst_typeFreeRADIUS type to convert to.
[in]dst_enumvEnumeration values to allow string to integer conversions.
[in]rootof the json-c tree.
[in]jpathto evaluate.
Returns
  • 1 on match.
  • 0 on no match.
  • -1 on error.

Definition at line 379 of file jpath.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ssize_t fr_jpath_parse ( TALLOC_CTX *  ctx,
fr_jpath_node_t **  head,
char const *  in,
size_t  inlen 
)

Parse a jpath string.

Based on the syntax described here http://goessner.net/articles/JsonPath/

Implements parser for everything except unions and expressions

Returns
  • > 0 on success.
  • <= 0 on error (* -1 to get offset error ocurred at).

Definition at line 817 of file jpath.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

size_t fr_json_from_pair ( char *  out,
size_t  outlen,
VALUE_PAIR const *  vp 
)

Prints attribute as string, escaped suitably for use as JSON string.

Returns < 0 if the buffer may be (or have been) too small to write the encoded JSON value to.

Parameters
outWhere to write the string.
outlenLenth of output buffer.
vpto print.
Returns
  • Length of data written to out.
  • value >= outlen on truncation.

Definition at line 150 of file json.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int fr_json_object_to_value_data ( TALLOC_CTX *  ctx,
value_data_t out,
json_object *  object,
PW_TYPE  dst_type,
fr_dict_attr_t const *  dst_enumv 
)

Convert json object to value_data_t.

Parameters
ctxto allocate any value buffers in (should usually be the same as out).
outWhere to write value_data.
objectto convert.
dst_typeFreeRADIUS type to convert to.
dst_enumvEnumeration values to allow string to integer conversions.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 42 of file json.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void fr_json_version_print ( void  )

Print JSON-C version.

Definition at line 265 of file json.c.

+ Here is the caller graph for this function: