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 onParse

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

Overview

Concrete key-value processor that classifies each request key into SQL conditions, reference keys, subqueries, function calls, or custom values, routing them to the appropriate processing pipeline, provided by the APIJSON ORM framework.

Description

The onParse method on AbstractObjectParser is called for every key-value pair in a table object during parse(). It classifies each key:

  • key@ (String value): Reference key — resolves a path reference (e.g., "userId@": "/Moment/userId") to link this table's column to another object's value in the request tree
  • key@ (Map value): Subquery — parses a key{}@ subquery specification, creates a Subquery object with inner SQLConfig
  • key(): Function call — adds to functionMap for post-SQL execution
  • @-prefixed keys: Directives — @column, @group, @order, @combine, @having, @raw, etc. added to sqlRequest
  • Regular keys: SQL conditions — added to sqlRequest for WHERE clause generation

For reference keys (key@ with String value), the method:

  1. Resolves the target path (e.g., "/Moment/userId") to an absolute path
  2. Calls onReferenceParse(targetPath) to look up the referenced value
  3. If the target is not yet available (dependency), the reference is deferred
  4. If resolved, the value is substituted into sqlRequest

Usage

Called internally by AbstractObjectParser.parse() for each entry in the request map. Not typically called directly.

Code Reference

Source Location

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

Signature

public boolean onParse(@NotNull String key, @NotNull Object value) throws Exception

Parameters:

  • key - Request key (may contain suffixes: @, (), {}, [])
  • value - Associated value

Returns: boolean - Whether parsing succeeded

Import

import apijson.orm.AbstractObjectParser;

I/O Contract

Inputs

Name Type Required Description
key String Yes Request key with optional suffix/prefix
value Object Yes Key value (String, Map, List, etc.)

Outputs

Name Type Description
return boolean Whether parse succeeded
sqlRequest M Updated with WHERE conditions and directives
functionMap Map Updated with function calls
customMap Map Updated with custom key-values

Usage Examples

Reference Key Resolution

// Request: { "Moment": { "userId@": "/User/id" }, "User": { "id": 82001 } }
// onParse("userId@", "/User/id"):
// 1. Resolve path: /User/id
// 2. onReferenceParse("/User/id") returns 82001
// 3. sqlRequest.put("userId", 82001)
// 4. Generated SQL: WHERE userId = 82001

Subquery Key

// Request: { "Moment": { "id{}@": { "from": "Comment", "Comment": { "userId": 82001 } } } }
// onParse("id{}@", { "from": "Comment", ... }):
// 1. Detects Map value (subquery)
// 2. Parses range, from, key
// 3. Creates Subquery with inner SQLConfig
// 4. Substitutes value as Subquery object

Related Pages

Implements Principle

Requires Environment

Page Connections

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