JSON Integration
Forms4s is designed to support any json library but currently only circe integration is available.
Usage
"org.business4s" %% "forms4s-circe" % "0.1.0"
val formState: FormElementState = ???
// Extract form data as JSON
import forms4s.circe.*
val formData: Json = formState.extractJson
// Load JSON into a form
val rebuiltState: FormElementState = formState.load(formData)
Limitations
- Currently hydration doesn't work for non-delimited alternatives
- Hydration errors (e.g. unmatched fields) are silently ignored
Example values
Table below show json extracted from various form elements
| FormElement Type | Empty Value | Example Value |
|---|---|---|
| Text | |
|
| Number (Decimal) | |
|
| Select | |
|
| Checkbox | |
|
Group
|
|
|
| Multivalue | |
|
Alternative
|
|
|