Skip to content

Commit 2595737

Browse files
peterjumpnlakoclaude
authored
feat: SHOW/DESCRIBE/CREATE/DROP JSON STRUCTURE (#80)
* feat: add JSON STRUCTURE DDL commands and catalog integration. Adds CREATE/DROP/SHOW/DESCRIBE JSON STRUCTURE statements for defining JSON structures - Add JSON STRUCTURE grammar rules with SNIPPET and CUSTOM NAME MAP - Add json_structures catalog table tracking element count and snippet - Add STRUCTURES and CUSTOM_NAME_MAP lexer tokens - Add ShowJsonStructures and DescribeJsonStructure to AST query types - Add buildJsonStructures() to catalog builder * bug fix UTF-8 refactor: simplify capitalizeFirstRune using unicode.ToUpper. Replace strings.ToUpper roundtrip with direct unicode.ToUpper call for cleaner single-rune capitalization. * fix: address review feedback on JSON STRUCTURE PR - Sort custom name map keys for deterministic DESCRIBE output - Check errors from json.Decoder.Token() and Decode() in snippet parser - Add comment explaining why JsonElement uses int32 (verified vs Studio Pro) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Andrej Koelewijn <andrej@koelewijn.net> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent e6aeaca commit 2595737

31 files changed

+13751
-11297
lines changed

.claude/skills/mendix/rest-client.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,34 @@ Use this skill when creating, modifying, or calling Consumed REST Clients in MDL
88
- Calling REST service operations from microflows (`SEND REST REQUEST`)
99
- Listing or inspecting REST clients (`SHOW REST CLIENTS`, `DESCRIBE REST CLIENT`)
1010

11+
## JSON Structures
12+
13+
Define JSON structures from a sample snippet before creating import/export mappings.
14+
15+
```sql
16+
CREATE JSON STRUCTURE Module.Name SNIPPET '{"id": 1, "name": "John"}';
17+
18+
-- Multi-line (use $$ quoting)
19+
CREATE JSON STRUCTURE Module.Name SNIPPET $${ "id": 1, "items": [{"name": "A"}] }$$;
20+
21+
-- With documentation
22+
CREATE JSON STRUCTURE Module.Name COMMENT 'API response' SNIPPET '...';
23+
24+
-- Custom name mapping for non-English keys
25+
CREATE JSON STRUCTURE Module.Name SNIPPET $${"kvkNummer": "123"}$$
26+
CUSTOM NAME MAP ('kvkNummer' AS 'ChamberOfCommerceNumber');
27+
28+
-- Idempotent update
29+
CREATE OR REPLACE JSON STRUCTURE Module.Name SNIPPET '...';
30+
31+
-- Browse and delete
32+
SHOW JSON STRUCTURES;
33+
DESCRIBE JSON STRUCTURE Module.Name;
34+
DROP JSON STRUCTURE Module.Name;
35+
```
36+
37+
Type inference: ISO 8601 strings → DateTime, integers → Integer, decimals → Decimal, booleans → Boolean. Snippet is auto-formatted when stored.
38+
1139
## CREATE REST CLIENT
1240

1341
```sql

cmd/mxcli/lsp_completions_gen.go

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/01-project/MDL_QUICK_REFERENCE.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,18 @@ CREATE OR REPLACE NAVIGATION Responsive
332332

333333
**Export levels:** `'Hidden'` (default, internal to module), `'Public'` (accessible from other modules).
334334

335+
## JSON Structures
336+
337+
| Statement | Syntax | Notes |
338+
|-----------|--------|-------|
339+
| Show structures | `SHOW JSON STRUCTURES [IN Module];` | List all or filter by module |
340+
| Describe structure | `DESCRIBE JSON STRUCTURE Module.Name;` | Re-executable CREATE OR REPLACE + element tree |
341+
| Create structure | `CREATE JSON STRUCTURE Module.Name [COMMENT 'text'] SNIPPET '...json...';` | Element tree auto-built from snippet |
342+
| Create (multi-line) | `CREATE JSON STRUCTURE Module.Name SNIPPET $${ "key": "value" }$$;` | Dollar-quoted snippet for readability |
343+
| Create or replace | `CREATE OR REPLACE JSON STRUCTURE Module.Name SNIPPET '...';` | Idempotent — preferred for AI agents |
344+
| Create with name map | `CREATE JSON STRUCTURE Module.Name SNIPPET '...' CUSTOM NAME MAP ('jsonKey' AS 'CustomName', ...);` | Override auto-generated ExposedNames |
345+
| Drop structure | `DROP JSON STRUCTURE Module.Name;` | |
346+
335347
## Java Actions
336348

337349
| Statement | Syntax | Notes |

0 commit comments

Comments
 (0)