Axis2/C supports JSON processing through two distinct architectures:
| Aspect | HTTP/1.1 JSON | HTTP/2 JSON |
|---|---|---|
| Source Files | axis2_json_reader.c, axis2_json_writer.c | axis2_h2_transport_utils.c |
| JSON Library | json-c | json-c |
| Internal Format | AXIOM XML tree (axiom_node_t*) | Native JSON (json_object*) |
| SOAP Handling | Full SOAP envelope processing | Minimal dummy envelope (bypassed) |
| Performance | Slower (JSON↔AXIOM conversion) | Faster (direct JSON processing) |
| Recommendation | Legacy/backward compatibility | Recommended for new development |
┌─────────────┐ ┌──────────────────────┐ ┌─────────────────┐ ┌─────────────┐
│ JSON Input │────▶│ axis2_json_reader.c │────▶│ axiom_node_t* │────▶│ SOAP/Engine │
│ │ │ (json-c parsing + │ │ (XML tree) │ │ Processing │
│ │ │ AXIOM conversion) │ │ │ │ │
└─────────────┘ └──────────────────────┘ └─────────────────┘ └─────────────┘
│
▼
┌──────────────────────┐
│ axis2_json_read_node │
│ (recursive JSON→XML) │
└──────────────────────┘
Key Functions:
axis2_json_reader_create_for_memory() - Creates reader from JSON stringaxis2_json_reader_read() - Parses JSON and converts to AXIOM treeaxis2_json_reader_get_root_node() - Returns axiom_node_t* (NOT json_object*)┌─────────────┐ ┌──────────────────────┐ ┌─────────────────┐ ┌─────────────┐
│ JSON Input │────▶│ json_tokener_parse() │────▶│ json_object* │────▶│ Service │
│ │ │ (direct json-c) │ │ (native JSON) │ │ Handler │
└─────────────┘ └──────────────────────┘ └─────────────────┘ └─────────────┘
│
▼
┌─────────────────────┐
│ Minimal SOAP Envelope│
│ (framework compat, │
│ processing bypassed)│
└─────────────────────┘
Key Functions:
json_tokener_parse() - Direct json-c parsingaxis2_h2_transport_utils_process_http_post_request() - HTTP/2 JSON handlerjson_object*The HTTP/1.1 path incurs significant overhead because:
axis2_json_read_node() recursively builds XML tree/* HTTP/1.1: JSON → AXIOM conversion (axis2_json_reader.c) */ axis2_status_t axis2_json_read_node( json_object* parent, /* Input: JSON object */ const char* name, axiom_node_t** om_node, /* Output: AXIOM XML node */ const axutil_env_t* env) { /* Recursive conversion of every JSON element to XML */ json_object_object_foreach(parent, key, value) { /* Create AXIOM element for each JSON key */ /* Recursively process nested objects/arrays */ } }
The HTTP/2 path eliminates conversion overhead:
json_object* directly/* HTTP/2: Direct JSON processing (axis2_h2_transport_utils.c) */ axis2_status_t axis2_h2_transport_utils_process_http_post_request( const axutil_env_t* env, axutil_stream_t* in_stream, const axis2_char_t* content_type) { /* Parse JSON directly - no conversion */ json_obj = json_tokener_parse(json_string); /* Service receives json_object* directly */ /* No AXIOM overhead */ }
HTTP/2 mode uses a “dummy SOAP envelope” pattern (similar to Axis2/Java):
IS_JSON_STREAM=true flag signals JSON-only modeThis achieves framework compatibility with near-zero overhead.
Both JSON paths are tested by dedicated fuzzers:
| Fuzzer | Tests | Entry Point |
|---|---|---|
fuzz_json_reader | HTTP/1.1 JSON→AXIOM | axis2_json_reader_create_for_memory() |
fuzz_json_parser | HTTP/2 direct json-c | json_tokener_parse() |
See fuzz/fuzz_json_reader.c and fuzz/fuzz_json_parser.c for implementation details.