Implementation:APIJSON APIJSON Demo JSONObject JS
| Knowledge Sources | |
|---|---|
| Domains | API_Design, JSON_Parsing, Frontend |
| Last Updated | 2026-10-14 00:00 GMT |
Overview
Concrete tool for identifying APIJSON key types (table keys, array keys, function keys) and common JSON object operations in the APIJSON Demo frontend.
Description
The JSONObject JavaScript module provides utility functions for determining whether a JSON key represents a table name, array name, or function call based on APIJSON naming conventions. It uses regex patterns (e.g., /^[A-Z][A-Za-z0-9_]*$/) to distinguish table keys from function keys. It also provides isEmpty and log helpers.
Usage
Import this module when you need to parse or validate APIJSON key structures in browser-side JavaScript code.
Code Reference
Source Location
- Repository: APIJSON_APIJSON_Demo
- File: APIJSON-Java-Server/APIJSONBoot-MultiDataSource/src/main/resources/static/api/apijson/JSONObject.js
- Lines: 1-138
Signature
var JSONObject = {
TAG: 'JSONObject',
log: function(tag, msg),
isEmpty: function(obj),
isTableKey: function(key, value, isRestful),
isArrayKey: function(key, value, isRestful),
isPathKey: function(key, value, isRestful),
isFunctionKey: function(key, value, isRestful),
// ...
};
Import
var JSONObject = require("./JSONObject");
// or via script tag in browser
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| key | String | Yes | JSON key to classify |
| value | Any | No | JSON value associated with key |
| isRestful | Boolean | No | Whether RESTful URL mode is active |
Outputs
| Name | Type | Description |
|---|---|---|
| isTableKey() returns | Boolean | Whether key matches table name pattern |
| isArrayKey() returns | Boolean | Whether key matches array name pattern |
| isFunctionKey() returns | Boolean | Whether key contains function call syntax |
Usage Examples
Classify a JSON Key
var JSONObject = require("./JSONObject");
// Table keys start with uppercase
console.log(JSONObject.isTableKey("User")); // true
console.log(JSONObject.isTableKey("id")); // false
// Array keys end with []
console.log(JSONObject.isArrayKey("User[]")); // true
console.log(JSONObject.isArrayKey("User")); // false