Implementation:APIJSON APIJSON Demo DemoFunctionParser RawSQL
| Knowledge Sources | |
|---|---|
| Domains | Database, SQL_Execution, Business_Logic |
| Last Updated | 2026-10-14 00:00 GMT |
Overview
Concrete tool for executing raw SQL queries and manipulating request keys via remote functions in the APIJSON RawSQL demo.
Description
The DemoFunctionParser class (RawSQL variant) extends APIJSONFunctionParser<String> and provides remotely callable functions: getCurrentUserId (session-based), sayHello (demo greeting), rawSQL (executes pre-defined SQL from the Request table's sqlauto field with parameterized prepared statements), and removeKeys (deletes keys from the current request object, supporting both array and semicolon-delimited formats).
Usage
Use these functions in APIJSON request bodies when the RawSQL demo needs server-side raw SQL execution or request key manipulation.
Code Reference
Source Location
- Repository: APIJSON_APIJSON_Demo
- File: APIJSON-Java-Server/APIJSONDemo-RawSQL/src/main/java/apijson/demo/DemoFunctionParser.java
- Lines: 1-187
Signature
public class DemoFunctionParser extends APIJSONFunctionParser<String> {
public String getCurrentUserId(@NotNull JSONObject current) throws IllegalAccessException;
public String sayHello(@NotNull JSONObject current, @NotNull String name) throws Exception;
public Object rawSQL(@NotNull JSONObject current, @NotNull String paramName);
public void removeKeys(@NotNull JSONObject current, String keys);
private Object buildSearchData(JSONObject current, String datasource, String sqlauto, String paramName);
}
Import
import apijson.demo.DemoFunctionParser;
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| current | JSONObject | Yes | Current request node |
| paramName | String | Yes | Parameter array key for prepared statement params |
| name | String | No | Key name for sayHello function |
| keys | String | No | Key name(s) for removeKeys function |
Outputs
| Name | Type | Description |
|---|---|---|
| rawSQL() returns | Object | List of JSONObject rows from prepared statement |
| sayHello() returns | String | Greeting string |
| getCurrentUserId() returns | String | Session visitor ID |
Usage Examples
Execute Raw SQL via APIJSON
// APIJSON request using rawSQL function
{
"[]": {
"User": {
"list()": "rawSQL(paramName)"
},
"paramName": ["name"],
"name": "test"
}
}
// Executes: SELECT * FROM ... WHERE name = ? with param "test"