Principle:APIJSON APIJSON Key Value Processing
| Knowledge Sources | |
|---|---|
| Domains | API_Design, Request_Processing, DSL |
| Last Updated | 2026-10-11 00:00 GMT |
Overview
A key-suffix classification system that routes request JSON key-value pairs to the correct processing pipeline based on syntactic conventions: SQL conditions, directives, references, function calls, or child objects.
Description
In the APIJSON request DSL, the meaning of a key is determined by its suffix and prefix:
- key (plain) → SQL WHERE condition (e.g., "id": 1 → WHERE id = 1)
- key>, key<, key~, key{} etc. → SQL conditions with operators (suffix encodes the operator)
- @key → Global or per-object directive (@column, @group, @order, @combine, @role, @method)
- key@ → Reference key (path reference to another object in the tree, e.g., "userId@": "/Moment/userId")
- key() → Function call (e.g., "isContain(praiseUserIdList,userId)")
- key[] → Array key (paginated child query)
- key:{} → Child object (nested table operation)
This suffix-based classification system allows a single flat JSON object to express a complex query with conditions, joins, subqueries, and function calls without any special syntax beyond key naming conventions.
The problem solved is the ambiguity of JSON keys: without a classification system, every key would need a separate metadata field to specify its role. By using suffixes, the DSL remains compact and readable while supporting a rich set of operations.
Usage
Use this principle when designing a JSON-based query DSL where different key types need different processing. The suffix-based approach keeps the syntax clean and allows the parser to efficiently route keys to the correct handler.
Theoretical Basis
The key classification algorithm:
# Abstract algorithm (NOT real implementation):
def classify_key(key, value):
if key.startswith("@"):
return "directive" # @column, @group, @order, @combine, @role
if key.endswith("()"):
return "function_call" # isContain(array, key)
if key.endswith("@"):
if isinstance(value, str):
return "reference" # key@: "/path/to/target"
elif isinstance(value, dict):
return "subquery" # key{}@: { "from": "Comment", ... }
if key.endswith("[]"):
return "array" # key[]: paginated child query
if isinstance(value, dict):
return "child_object" # key: { nested table }
# Extract operator from suffix
operator = parse_operator_suffix(key) # >, <, >=, <=, {}, ~, <>(), etc.
return ("condition", operator) # Regular WHERE condition
Related Pages
Implemented By
- Implementation:APIJSON_APIJSON_AbstractObjectParser_parse
- Implementation:APIJSON_APIJSON_AbstractObjectParser_onParse
- Implementation:APIJSON_APIJSON_StringUtil