Skip to content

Commit e62ec70

Browse files
committed
feat: adicionar suporte para arquivos JSON como pontos de entrada no guia de sintaxe avançada
1 parent 2418237 commit e62ec70

2 files changed

Lines changed: 33 additions & 0 deletions

File tree

site/docs/advanced-syntax.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,35 @@ Phlow uses a **4-stage preprocessor pipeline** that transforms your `.phlow` fil
2020
3. **Script Evaluation** - Converts `!phs` blocks to executable format
2121
4. **Module Transformation** - Converts shorthand module calls to standard format
2222

23+
## JSON Flow Support
24+
25+
Phlow also accepts `.json` files as entry points. The structure mirrors the YAML version, only serialized as JSON:
26+
27+
```json
28+
{
29+
"modules": [
30+
{ "module": "log" }
31+
],
32+
"steps": [
33+
{
34+
"use": "log",
35+
"input": {
36+
"message": "Hello from JSON"
37+
}
38+
}
39+
]
40+
}
41+
```
42+
43+
- `.json` entry points skip the preprocessor entirely. Features such as `!include`, `!import`, auto `!phs`, and shorthand module conversion **do not run**, so write the flow in its final form (`use` + `input`).
44+
- Inspect JSON flows with the CLI using `--print --output json` to preserve the original format:
45+
46+
```bash
47+
cargo run -p phlow-runtime -- ./flows/open.json --print --output json
48+
```
49+
50+
- When a `!include` references a file with an explicit extension other than `.phlow` (for example, `.json`), the content is inserted as-is. This is handy for embedding JSON payload samples or schemas inside a YAML-based flow.
51+
2352
## Preprocessor Pipeline
2453

2554
### Stage 1: Directives Processing

site/docs/advanced/advanced-syntax.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ title: Advanced Syntax
77

88
This guide covers advanced Phlow syntax including enhanced module patterns and code block support for complex workflows.
99

10+
## JSON Entry Points
11+
12+
Phlow can load `.json` files directly as the main flow. Because the preprocessor is bypassed, keep the document in its fully expanded shape (for example, use `use` + `input` blocks instead of shorthand module syntax) and avoid directives such as `!include` or `!import`. To inspect the parsed structure, run `cargo run -p phlow-runtime -- ./flows/open.json --print --output json`. Any `!include` pointing to a file with an explicit non-`.phlow` extension—such as `.json`—injects the raw content, which is useful for bundling payload samples or schemas with YAML-based flows.
13+
1014
## Enhanced Module Syntax
1115

1216
### Automatic Transformation

0 commit comments

Comments
 (0)