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 AbstractParser extendSuccessResult

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

Overview

Concrete response assembler that adds success status fields (code, msg) to the response tree and optionally formats response keys based on the @format directive, provided by the APIJSON ORM framework.

Description

The extendSuccessResult' method on AbstractParser wraps the parsed response tree with standard status fields:

  • code: 200 (success code from JSONResponse.CODE_SUCCESS)
  • msg: "success" (from JSONResponse.MSG_SUCCEED)
  • warn: Optional warning message

The method delegates to extendResult() which recursively adds code and msg to the root response object and any child response objects. When globalFormat == true and the response is a success, JSONResponse.format() is called to convert keys to camelCase/other case formats.

Usage

Called internally by parseResponse() after successful parsing. Not typically called directly.

Code Reference

Source Location

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

Signature

public M extendSuccessResult(M object)

public M extendSuccessResult(M object, boolean isRoot)

public M extendSuccessResult(M object, String warn, boolean isRoot)

Parameters:

  • object - Response tree from parsing
  • warn - Optional warning message
  • isRoot - Whether this is the root response object

Returns: M - Response with code, msg added

Import

import apijson.orm.AbstractParser;

I/O Contract

Inputs

Name Type Required Description
object M Yes Parsed response tree
warn String No Warning message
isRoot boolean Yes Root flag

Outputs

Name Type Description
return M Response with code=200, msg="success"

Usage Examples

Success Response

// After successful parsing:
// requestObject = extendSuccessResult(requestObject, null, true);
// Result: { "code": 200, "msg": "success", "User": { "id": 82001, ... } }

With Format

// When globalFormat = true:
// JSONResponse.format(requestObject) converts keys:
// "user_id" -> "userId", "created_at" -> "createdAt"
// { "code": 200, "msg": "success", "User": { "userId": 82001, "createdAt": "..." } }

Related Pages

Implements Principle

Requires Environment

Page Connections

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