Adaptive Framework  0.9.0
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
afw_json.h
Go to the documentation of this file.
1 // See the 'COPYING' file in the project root for licensing information.
2 /*
3  * Adaptive Framework JSON
4  *
5  * Copyright (c) 2010-2023 Clemson University
6  *
7  */
8 
9 #ifndef __AFW_JSON_H__
10 #define __AFW_JSON_H__
11 
12 #include "afw_minimal.h"
13 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
32 #define AFW_JSON_Q_CONTENT_TYPE "application/json"
33 #define AFW_JSON_S_CONTENT_TYPE afw_s_a_application_json
34 #define AFW_JSON_Q_CONTENT_TYPE_SHORT "json"
35 #define AFW_JSON_S_CONTENT_TYPE_SHORT afw_s_json
36 
37 
38 #define AFW_JSON_PN_JSON_PRIMITIVE AFW_Q_jsonPrimitive
39 #define AFW_JSON_PN_s_JSON_PRIMITIVE afw_s_jsonPrimitive
40 #define AFW_JSON_Q_PRIMITIVE_OBJECT AFW_Q_object
41 #define AFW_JSON_S_PRIMITIVE_OBJECT afw_s_object
42 #define AFW_JSON_Q_PRIMITIVE_ARRAY AFW_Q_array
43 #define AFW_JSON_S_PRIMITIVE_ARRAY afw_s_array
44 #define AFW_JSON_Q_PRIMITIVE_NUMBER AFW_Q_number
45 #define AFW_JSON_S_PRIMITIVE_NUMBER afw_s_number
46 #define AFW_JSON_Q_PRIMITIVE_STRING AFW_Q_string
47 #define AFW_JSON_S_PRIMITIVE_STRING afw_s_string
48 #define AFW_JSON_Q_PRIMITIVE_BOOLEAN AFW_Q_boolean
49 #define AFW_JSON_S_PRIMITIVE_BOOLEAN afw_s_boolean
50 #define AFW_JSON_Q_PRIMITIVE_NULL AFW_Q_null
51 #define AFW_JSON_S_PRIMITIVE_NULL afw_s_null
52 #define AFW_JSON_Q_PRIMITIVE_BOOLEAN_TRUE AFW_Q_true
53 #define AFW_JSON_S_PRIMITIVE_BOOLEAN_TRUE afw_s_true
54 #define AFW_JSON_Q_PRIMITIVE_BOOLEAN_FALSE AFW_Q_false
55 #define AFW_JSON_S_PRIMITIVE_BOOLEAN_FALSE afw_s_false
56 
57 #define AFW_JSON_Q_INFINITY "Infinity"
58 #define AFW_JSON_Q_MINUS_INFINITY "-Infinity"
59 #define AFW_JSON_Q_NAN "NaN"
60 #define AFW_JSON_Q_MINUS_NAN "-NaN"
61 
77 #define AFW_JSON_Q_PN_META AFW_OBJECT_Q_PN_META
78 #define AFW_JSON_Q_PN_ID AFW_OBJECT_Q_PN_ID
79 #define AFW_JSON_Q_PN_PATH AFW_OBJECT_Q_PN_PATH
80 #define AFW_JSON_Q_PN_OBJECT_TYPE AFW_OBJECT_Q_PN_OBJECT_TYPE
81 #define AFW_JSON_Q_PN_PARENT_PATH AFW_OBJECT_Q_PN_PARENT_PATH
82 
83 
89 
90 
98 AFW_DECLARE(void)
100 
111 AFW_DECLARE(const afw_utf8_t *)
113  const afw_value_t *value,
114  const afw_object_options_t *options,
115  const afw_pool_t *p, afw_xctx_t *xctx);
116 
128 #define afw_json_to_value(json, source_location, p, xctx) \
129  afw_compile_to_value(json, source_location, \
130  afw_compile_type_relaxed_json, \
131  NULL, NULL, p, xctx)
132 
133 
142 #define afw_json_to_object(string, cede_p, p, xctx) \
143  afw_compile_to_object(string, NULL, NULL, NULL, NULL, \
144  cede_p, p, xctx)
145 
146 
167 #define afw_json_to_object_with_meta(string, source_location, \
168  adaptor_id, object_type_id, object_id, \
169  cede_p, p, xctx) \
170  afw_compile_to_object(string, source_location, \
171  adaptor_id, object_type_id, object_id, \
172  cede_p, p, xctx)
173 
174 
181 AFW_DECLARE(void)
183  const afw_utf8_t *string,
184  const afw_writer_t *writer,
185  afw_xctx_t *xctx);
186 
187 
188 
195 AFW_DEFINE(const afw_utf8_t *)
197  const afw_utf8_t *string,
198  const afw_pool_t *p,
199  afw_xctx_t *xctx);
200 
201 
202 AFW_END_DECLARES
203 
206 #endif /* __AFW_JSON_H__ */
AFW_DEFINE(const afw_object_t *)
#define AFW_DECLARE(type)
Declare a public afw function.
Adaptive Framework Minimal Header.
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.
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.
void afw_json_register(afw_xctx_t *xctx)
Register JSON support.
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.
const afw_content_type_t * afw_json_content_type_get()
Get the content type instance for json.
Definition: afw_json.c:65
Interface afw_content_type public struct.
Struct for object processing options.
Interface afw_pool public struct.
NFC normalized UTF-8 string.
Definition: afw_common.h:545
Interface afw_value public struct.
Interface afw_writer public struct.
Interface afw_xctx public struct.