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

Implementation:APIJSON APIJSON AbstractObjectParser parse

From Leeroopedia
Knowledge Sources
Domains ORM, Request_Processing, Recursive_Parsing
Last Updated 2026-10-11 00:00 GMT

Overview

Concrete per-object parser that processes all key-value pairs of a single table object, routing them to SQL conditions, child objects, function calls, or custom maps, provided by the APIJSON ORM framework.

Description

The parse method on AbstractObjectParser is the per-object lifecycle handler. For each table object in the request, it iterates through all key-value pairs and classifies them:

  • @-prefixed keys → configuration directives (@column, @group, @order, @combine, etc.)
  • key@ → reference keys (path references to other objects)
  • key() → function call keys (remote function invocations)
  • key[] → array/child keys (nested table queries)
  • key:{} → child objects (nested table operations)
  • Regular keys → SQL WHERE conditions (e.g., id, name~, id{})

The method separates keys into sqlRequest (WHERE conditions and directives), functionMap (function calls to execute after SQL), customMap (non-SQL custom values), and childMap (child table results). After processing, it provides setSQLConfig().executeSQL().response() chaining.

Usage

Called internally by AbstractParser.onObjectParse. Override parse in a subclass to customize key processing logic, such as adding custom key types or modifying how specific keys are routed.

Code Reference

Source Location

  • Repository: APIJSON
  • File: src/main/java/apijson/orm/AbstractObjectParser.java

Signature

public AbstractObjectParser<T, M, L> parse(String name, boolean isReuse) throws Exception

Parameters:

  • name - Key name in Table:alias format
  • isReuse - Whether to reuse cached parser state (for array main table at position > 0)

Returns: AbstractObjectParser<T,M,L> - this (for chaining), or null if invalidated

Import

import apijson.orm.AbstractObjectParser;

I/O Contract

Inputs

Name Type Required Description
name String Yes Table key name (Table:alias format)
isReuse boolean Yes Whether reusing cached state for array pagination
request M Yes The object's key-value pairs (set during construction)
method RequestMethod Yes HTTP method for this object

Outputs

Name Type Description
return AbstractObjectParser this for chaining, or null if invalidated
response M Assembled response map for this object
sqlRequest M WHERE conditions and SQL directives
functionMap Map<String,Map<String,String>> Collected function calls
customMap Map<String,Object> Non-SQL custom key-values
childMap Map<String,M> Child table results

Usage Examples

Chaining Pattern

// After parse() completes, the ObjectParser is used in a fluent chain:
// op.parse(name, isReuse)
//   .setSQLConfig()       // Build SQLConfig from sqlRequest
//   .executeSQL()          // Execute SQL via SQLExecutor
//   .response();           // Extract response map

// Internal flow:
// 1. parse() iterates request keys
// 2. onParse(key, value) classifies each key
// 3. SQL conditions → sqlRequest
// 4. Function calls → functionMap (executed after SQL)
// 5. Child objects → childMap (recursively parsed)
// 6. Custom keys → customMap

Key Classification

// Request: {
//   "id{}": [1, 2, 3],        // → sqlRequest (WHERE id IN (1,2,3))
//   "name~": "Tom",            // → sqlRequest (WHERE name LIKE 'Tom')
//   "@column": "id,name",      // → sqlRequest (SELECT id, name)
//   "Comment[]": { ... },      // → childMap (nested array query)
//   "isContain(idList, 82001)": "isContain",  // → functionMap
//   "customKey": "customValue" // → customMap
// }

Related Pages

Implements Principle

Requires Environment

Page Connections

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