Adaptive Framework  0.9.0
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
Files | Macros | Functions

Files

file  afw_json.h
 Header file for Adaptive Framework JSON.
 

Macros

#define AFW_JSON_Q_CONTENT_TYPE   "application/json"
 
#define AFW_JSON_S_CONTENT_TYPE   afw_s_a_application_json
 
#define AFW_JSON_Q_CONTENT_TYPE_SHORT   "json"
 
#define AFW_JSON_S_CONTENT_TYPE_SHORT   afw_s_json
 
#define AFW_JSON_PN_JSON_PRIMITIVE   AFW_Q_jsonPrimitive
 
#define AFW_JSON_PN_s_JSON_PRIMITIVE   afw_s_jsonPrimitive
 
#define AFW_JSON_Q_PRIMITIVE_OBJECT   AFW_Q_object
 
#define AFW_JSON_S_PRIMITIVE_OBJECT   afw_s_object
 
#define AFW_JSON_Q_PRIMITIVE_ARRAY   AFW_Q_array
 
#define AFW_JSON_S_PRIMITIVE_ARRAY   afw_s_array
 
#define AFW_JSON_Q_PRIMITIVE_NUMBER   AFW_Q_number
 
#define AFW_JSON_S_PRIMITIVE_NUMBER   afw_s_number
 
#define AFW_JSON_Q_PRIMITIVE_STRING   AFW_Q_string
 
#define AFW_JSON_S_PRIMITIVE_STRING   afw_s_string
 
#define AFW_JSON_Q_PRIMITIVE_BOOLEAN   AFW_Q_boolean
 
#define AFW_JSON_S_PRIMITIVE_BOOLEAN   afw_s_boolean
 
#define AFW_JSON_Q_PRIMITIVE_NULL   AFW_Q_null
 
#define AFW_JSON_S_PRIMITIVE_NULL   afw_s_null
 
#define AFW_JSON_Q_PRIMITIVE_BOOLEAN_TRUE   AFW_Q_true
 
#define AFW_JSON_S_PRIMITIVE_BOOLEAN_TRUE   afw_s_true
 
#define AFW_JSON_Q_PRIMITIVE_BOOLEAN_FALSE   AFW_Q_false
 
#define AFW_JSON_S_PRIMITIVE_BOOLEAN_FALSE   afw_s_false
 
#define AFW_JSON_Q_INFINITY   "Infinity"
 
#define AFW_JSON_Q_MINUS_INFINITY   "-Infinity"
 
#define AFW_JSON_Q_NAN   "NaN"
 
#define AFW_JSON_Q_MINUS_NAN   "-NaN"
 
#define AFW_JSON_Q_PN_META   AFW_OBJECT_Q_PN_META
 
#define AFW_JSON_Q_PN_ID   AFW_OBJECT_Q_PN_ID
 
#define AFW_JSON_Q_PN_PATH   AFW_OBJECT_Q_PN_PATH
 
#define AFW_JSON_Q_PN_OBJECT_TYPE   AFW_OBJECT_Q_PN_OBJECT_TYPE
 
#define AFW_JSON_Q_PN_PARENT_PATH   AFW_OBJECT_Q_PN_PARENT_PATH
 
#define afw_json_to_value(json, source_location, p, xctx)
 Convert JSON to an adaptive value. More...
 
#define afw_json_to_object(string, cede_p, p, xctx)
 Compile json string to adaptive object. More...
 
#define afw_json_to_object_with_meta(string, source_location, adaptor_id, object_type_id, object_id, cede_p, p, xctx)
 Compile json string to adaptive object with meta. More...
 

Functions

const afw_content_type_tafw_json_content_type_get ()
 Get the content type instance for json.
 
void afw_json_register (afw_xctx_t *xctx)
 Register JSON support. More...
 
const afw_utf8_tafw_json_from_value (const afw_value_t *value, const afw_object_options_t *options, const afw_pool_t *p, afw_xctx_t *xctx)
 Convert an adaptive value to JSON. More...
 
void afw_json_write_encoded_string (const afw_utf8_t *string, const afw_writer_t *writer, afw_xctx_t *xctx)
 Write string as json encoded string. More...
 
 afw_json_utf8_string_create (const afw_utf8_t *string, const afw_pool_t *p, afw_xctx_t *xctx)
 Create a json encoded quoted string. More...
 

Detailed Description

Adaptive Framework JSON support

Macro Definition Documentation

◆ AFW_JSON_Q_PN_META

#define AFW_JSON_Q_PN_META   AFW_OBJECT_Q_PN_META

Property name "_meta_" of a special JSON object property whose value is an object. The properties of this object correspond to certain methods of the afw_object interface or carry additional information.

Property name Related method or purpose
objectId afw_object_meta_get_object_id()
path afw_object_meta_get_path()
objectType afw_object_meta_get_object_type()
parentPaths afw_object_meta_get_parent_paths()

Properties parentPaths and expanded can be included in input objects to

Definition at line 77 of file afw_json.h.

◆ afw_json_to_object

#define afw_json_to_object (   string,
  cede_p,
  p,
  xctx 
)
Value:
afw_compile_to_object(string, NULL, NULL, NULL, NULL, \
cede_p, p, xctx)
afw_compile_to_object(const afw_utf8_t *string, const afw_utf8_t *source_location, const afw_utf8_t *adaptor_id, const afw_utf8_t *object_type_id, const afw_utf8_t *object_id, afw_boolean_t cede_p, const afw_pool_t *p, afw_xctx_t *xctx)
Compile string to adaptive object.
Definition: afw_compile.c:313

Compile json string to adaptive object.

Parameters
stringto compile.
cede_pif true, cede control of p to the created object.
pto use.
xctxof caller.
Returns
object instance.

Definition at line 142 of file afw_json.h.

◆ afw_json_to_object_with_meta

#define afw_json_to_object_with_meta (   string,
  source_location,
  adaptor_id,
  object_type_id,
  object_id,
  cede_p,
  p,
  xctx 
)
Value:
afw_compile_to_object(string, source_location, \
adaptor_id, object_type_id, object_id, \
cede_p, p, xctx)

Compile json string to adaptive object with meta.

Parameters
stringto compile.
source_locationor NULL.
adaptor_idto use for created object.
object_type_idto use for created object.
object_idto use for created object.
cede_pif true, cede control of p to the created object.
pto use.
xctxof caller.
Returns
object instance.

If source_location is NULL and path is specified, adaptor_id, object_type_id, and object_id will be used to produce a path that will be used as the source location.

If adaptor_id is NULL, object_type_id and object_id must be NULL. If they're NULL, the object's meta will not be set.

Definition at line 167 of file afw_json.h.

◆ afw_json_to_value

#define afw_json_to_value (   json,
  source_location,
  p,
  xctx 
)
Value:
afw_compile_to_value(json, source_location, \
afw_compile_type_relaxed_json, \
NULL, NULL, p, xctx)
#define afw_compile_to_value(string, source_location, compile_type, parent, shared, p, xctx)
Compile string to adaptive value.
Definition: afw_compile.h:189

Convert JSON to an adaptive value.

Parameters
jsonJSON.
source_locationor NULL.
object_idOptional id of object if value is object or NULL.
pto use.
xctxof caller.
Returns
value

This function can be used for callbacks of type afw_utf8_to_value_t.

Definition at line 128 of file afw_json.h.

Function Documentation

◆ afw_json_from_value()

const afw_utf8_t* afw_json_from_value ( const afw_value_t value,
const afw_object_options_t options,
const afw_pool_t p,
afw_xctx_t xctx 
)

Convert an adaptive value to JSON.

Parameters
value
optionsor NULL.
pto use.
xctxof caller.
Returns
json

This function can be used for callbacks of type afw_utf8_from_value_t.

Definition at line 494 of file afw_json_from_value.c.

◆ afw_json_register()

void afw_json_register ( afw_xctx_t xctx)

Register JSON support.

Parameters
xctxof caller.

This is called by afw_environment_register_core.c to register JSON support.

◆ afw_json_utf8_string_create()

afw_json_utf8_string_create ( const afw_utf8_t string,
const afw_pool_t p,
afw_xctx_t xctx 
)

Create a json encoded quoted string.

Parameters
stringto encode.
pfor result.
Returns
Quoted string.

Definition at line 587 of file afw_json_from_value.c.

◆ afw_json_write_encoded_string()

void afw_json_write_encoded_string ( const afw_utf8_t string,
const afw_writer_t writer,
afw_xctx_t xctx 
)

Write string as json encoded string.

Parameters
stringto write.
writerto use.
xctxof caller.

Definition at line 513 of file afw_json_from_value.c.