Json Editor
Formsatlas-json-editorExamples
Validated JSON
[(value)] is the parsed value. Break the JSON to see the error under the editor; the value keeps its last valid state until the text parses again.
Valid JSON only.
Valid JSON
{
"email": true,
"sms": false,
"quietHours": {
"from": "22:00",
"to": "07:00"
}
}Large editor that never loses a value
A large standalone JSON editor with [allowEmpty]="false" : clearing the text does not wipe the stored value, Save stays disabled until the JSON is valid, and typing null clears it on purpose.
Saved: {
"name": "claims-auto-approval",
"version": 4,
"rules": [
{
"field": "amount",
"operator": "lte",
"value": 500
},
{
"field": "customer.tier",
"operator": "in",
"value": [
"gold",
"platinum"
]
}
],
"actions": {
"approve": true,
"notify": [
"claims-team"
]
}
}API
Generated from the library source, so it always matches the code.
AtlasJsonEditorComponent atlas-json-editor
| Input | Type | Default | Description |
|---|---|---|---|
| value two-way | unknown | null | null . |
| indent | number | 2 | |
| allowEmpty | boolean | true | null ). Turn it off when clearing the editor must not wipe a stored value: empty text is then invalid and the value keeps its last valid state (type null to clear). |
| showFormat | boolean | true | |
| placeholder | string | '' | |
| lineNumbers | boolean | true | |
| lineWrapping | boolean | false | |
| indentWithTab | boolean | false | |
| disabled | boolean | false | |
| errors | readonly ValidationError.WithOptionalFieldTree[] | [] | [field] . |
| required | boolean | false | [field] . |
| invalid | boolean | false | [field] . Invalid JSON marks it invalid too. |
| touched | boolean | false | [field] . |
| readonly | boolean | false | [field] . |
| pending | boolean | false | [field] . |
| name | string | '' | [field] . |
| ariaLabel | string | null | null | |
| inputId | string | undefined | undefined | id of the text surface. Inside atlas-form-field the field supplies one. |
| ariaDescribedBy | string | null | null | aria-describedby , merged with the parse error and the form field's hint or error. |
| editorClass | string | '' | h-80 ), merged with its own; yours win on conflicts. Plain class stays on the host, which also holds the Format button and the error line, so a height there would clip them. |
| Output | Payload | Description |
|---|---|---|
| touch | void | |
| validityChange | boolean | false when the text becomes invalid JSON and true when it parses again. |
Functions
| Function | Description |
|---|---|
| parseJsonText(text: string): AtlasJsonParseResult | null , anything else must be valid JSON. |
| stringifyJsonValue(value: unknown, indent: number): string | null and undefined are empty text. |
Types
AtlasJsonParseResult
type AtlasJsonParseResult = { ok: true; value: unknown } | { ok: false; error: string }