JSON
This field can be used to enter and display JSON data. The value is parsed using JSON.parse
before it is returned, and stringified before it is displayed.
Example
({
type: "json",
label: "JSON",
placeholder: "Enter your text here...",
})
Options
Input
Use these options when using the field with take
.
value? | The initial value of the field. |
key? | A key to access the value. If provided, each field must have a unique key. See make for more information about accessing values. |
label? | A label describing the purpose of the field. |
detail? | Additional information about the field, disclosed in a tooltip. |
placeholder? | Add placeholder text to prompt the user when the field is empty. |
spellcheck? | Enable or disable the browser’s spellchecking feature. |
pattern? | A regular expression that the input value must match in order for the value to pass validation. |
maxlength? | The maximum number of characters the user can enter into the input. |
Output
Use these options when using the field with make
.
value? | The output value of the field. |
replacer? | Alter the behavior of the stringification process. See MDN for more details. |
space? | Control the way white space is inserted into the JSON text. See MDN for more details. |
label? | A label describing the purpose of the field. |
detail? | Additional information about the field, disclosed in a tooltip. |
Data
A JSON field will always return an object or array. If the value is null or undefined, an empty object is returned. If the value cannot be parsed, an empty object is returned. Values must conform to the JSON specification, meaning object keys must use quotes.