Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Principle:APIJSON APIJSON Key Value Processing

From Leeroopedia
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

Uses Heuristic

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment