DataModule
A portable tree for structured data.
Summary
| Name | Signature | Synopsis |
|---|---|---|
| Union cases | ||
| IsBool | this.IsBool | No description available. |
| IsText | this.IsText | No description available. |
| IsNumber | this.IsNumber | No description available. |
| IsNull | this.IsNull | No description available. |
| IsObject | this.IsObject | No description available. |
| IsList | this.IsList | No description available. |
| From | Data.From(values) | Recursively converts a supported list, or converts a null list to Null. |
| From | Data.From(value) | Converts a calendar date to ISO text. |
| From | Data.From(value) | Converts a timestamp to round-trip ISO text. |
| From | Data.From(value) | Converts a GUID to canonical text. |
| From | Data.From(value) | Converts a double using invariant round-trip formatting. |
| From | Data.From(value) | Converts a decimal using invariant formatting. |
| From | Data.From(value) | Converts a 64-bit integer using invariant formatting. |
| From | Data.From(value) | Converts a 32-bit integer using invariant formatting. |
| From | Data.From(value) | Converts a Boolean value. |
| From | Data.From(value) | Converts text, or converts a null string to Null. |
| From | Data.From(value) | Returns an existing structured value unchanged. |
| Null | Null | A null value. |
| Text | Text value | A text value. |
| Number | Number token | A number whose portable lexical token avoids narrowing it to one runtime numeric type. |
| Bool | Bool value | A Boolean value. |
| List | List items | An ordered collection of structured values. |
| Object | Object fields | An ordered collection of named structured values. |
| Operations | ||
| assoc | Data.assoc name value | Associates an object field name with one exact value. |
| optionalAssoc | Data.optionalAssoc name value | Associates an object field name with Some value, or omits None. |
| data | Data.data fields | Builds an object from ordered field instructions. |
| fields | Data.fields value | Returns exact field instructions from an existing object. |
| number | Data.number token | Constructs a number from one JSON number token, validated identically on .NET and Fable. |
| objectOfMap | Data.objectOfMap | Builds an object from an F# map, ordered by key. |
| objectOfList | Data.objectOfList | Builds an object from ordered name and value pairs. |
| ofMap | Data.ofMap | Builds object-shaped data from a map of scalar values. |
| ofDictionary | Data.ofDictionary | Builds object-shaped data from a .NET dictionary of scalar values. |
| ofNameValues | Data.ofNameValues | Builds object-shaped data from name and value pairs. |
| ofNameValueCollection | Data.ofNameValueCollection | Builds object-shaped data from a .NET name-value collection. |
| ofCliArgs | Data.ofCliArgs | Builds structured data from command-line arguments. |
| ofJsonElement | Data.ofJsonElement | Copies a .NET 8+ System.Text.Json.JsonElement into structured data. |
| ofJsonDocument | Data.ofJsonDocument | Copies a .NET 8+ System.Text.Json.JsonDocument into structured data. |
| ofConfiguration | Data.ofConfiguration | Builds structured data from flattened configuration keys. |
| ofConfigurationPairs | Data.ofConfigurationPairs | Builds structured data from .NET configuration key and value pairs. |
| tryFind | Data.tryFind | Attempts to find a value at a parsed path. |
| lookup | Data.lookup | Finds a value at a parsed path or returns Null. |
| tryFindPath | Data.tryFindPath | Attempts to parse a path and find its value. |
| lookupPath | Data.lookupPath | Parses a path and finds its value or returns Null. |
| tryRedisplay | Data.tryRedisplay | Attempts to render one scalar value for redisplay. |
| redisplay | Data.redisplay | Renders one scalar value for redisplay. |
| tryRedisplayAt | Data.tryRedisplayAt | Attempts to redisplay a scalar at a parsed path. |
| redisplayAt | Data.redisplayAt | Redisplays a scalar at a parsed path. |
| tryRedisplayPath | Data.tryRedisplayPath | Attempts to parse a path and redisplay its scalar. |
| redisplayPath | Data.redisplayPath | Parses a path and redisplays its scalar. |
| tryPatch | Data.tryPatch edits input | Applies immutable edits atomically in declaration order. |
| patch | Data.patch edits input | Applies edits atomically or raises DataPatchException. |
| applyEdit | Data.applyEdit edit input | Applies one prepared edit or raises DataPatchException. |
| set | Data.set path value input | Replaces one value, or adds a missing final object field, and returns the changed tree. |
| replace | Data.replace path value input | Replaces one existing value and returns the changed tree. |
| remove | Data.remove path input | Removes one existing field or list item and returns the changed tree. |
| append | Data.append path value input | Appends one item to an existing list and returns the changed tree. |
| prepend | Data.prepend path value input | Prepends one item to an existing list and returns the changed tree. |
| insert | Data.insert path index value input | Inserts one item at a valid list index and returns the changed tree. |
| rename | Data.rename path name input | Renames one existing object field without moving it and returns the changed tree. |
| update | Data.update path change input | Applies one function to an existing value and returns the changed tree. |
| diff | Data.diff expected actual | Returns all exact structural differences between two values. |
| compare | Data.compare expected actual | Compares complete values and returns every structural difference. |
| tryMatch | Data.tryMatch expectations actual | Checks path-based expectations and accumulates structured mismatches. |
| render | Data.render input | Renders structured data in a compact, human-readable form. |
| renderIndented | Data.renderIndented input | Renders structured data in an indented, human-readable form. |
| tryText | Data.tryText _arg1 | Attempts to extract text from one structured value. |
| tryBool | Data.tryBool _arg1 | Attempts to extract a Boolean from one structured value. |
| tryNumberToken | Data.tryNumberToken _arg1 | Attempts to extract the preserved token from one number value. |
| tryList | Data.tryList _arg1 | Attempts to extract items from one list value. |
| tryObject | Data.tryObject _arg1 | Attempts to extract ordered fields from one object value. |
Union cases
kind:member
kind:member
kind:member
kind:member
kind:member
kind:member
kind:member
kind:member
kind:member
kind:member
kind:member
kind:member
kind:member
Operations
kind:member
kind:member
kind:member
kind:member
kind:member
kind:member
kind:member
kind:member
kind:member
kind:member
kind:member
kind:member
kind:member
kind:member
kind:member
kind:member
kind:member
kind:member
kind:member
kind:member
kind:member
kind:member
kind:member
kind:member
kind:member
kind:member
kind:member
Applies immutable edits atomically in declaration order.
Parameters
| Name | Type | Description |
|---|---|---|
| edits | DataEdit list | |
| input | Data |
Returns
Result<Data, DataPatchFailure list>
Verification Examples
Data.tryPatch [ replace "name" "Grace" ] (data [ "name" => "Ada" ])
// Ok (data [ "name" => "Grace" ])kind:member
Applies edits atomically or raises
DataPatchException.Parameters
| Name | Type | Description |
|---|---|---|
| edits | DataEdit list | |
| input | Data |
Returns
Data
Verification Examples
Data.data [ Data.assoc "name" "Ada" ]
|> Data.patch [ DataEdit.replace "name" "Grace" ]
// Data.data [ Data.assoc "name" "Grace" ]kind:member
kind:member
Replaces one value, or adds a missing final object field, and returns the changed tree.
Parameters
| Name | Type | Description |
|---|---|---|
| path | string | |
| value | ^a | |
| input | Data |
Returns
Data
Verification Examples
data [ "name" => "Ada" ] |> Data.set "active" true
// data [ "name" => "Ada"; "active" => true ]kind:member
kind:member
kind:member
Appends one item to an existing list and returns the changed tree.
Parameters
| Name | Type | Description |
|---|---|---|
| path | string | |
| value | ^a | |
| input | Data |
Returns
Data
Verification Examples
data [ "roles" => [ "author" ] ] |> Data.append "roles" "admin"
// data [ "roles" => [ "author"; "admin" ] ]kind:member
Prepends one item to an existing list and returns the changed tree.
Parameters
| Name | Type | Description |
|---|---|---|
| path | string | |
| value | ^a | |
| input | Data |
Returns
Data
Verification Examples
data [ "roles" => [ "admin" ] ] |> Data.prepend "roles" "author"
// data [ "roles" => [ "author"; "admin" ] ]kind:member
Inserts one item at a valid list index and returns the changed tree.
Parameters
| Name | Type | Description |
|---|---|---|
| path | string | |
| index | int | |
| value | ^a | |
| input | Data |
Returns
Data
Verification Examples
data [ "roles" => [ "author" ] ] |> Data.insert "roles" 1 "admin"
// data [ "roles" => [ "author"; "admin" ] ]kind:member
Renames one existing object field without moving it and returns the changed tree.
Parameters
| Name | Type | Description |
|---|---|---|
| path | string | |
| name | string | |
| input | Data |
Returns
Data
Verification Examples
data [ "name" => "Ada" ] |> Data.rename "name" "displayName"
// data [ "displayName" => "Ada" ]kind:member
Applies one function to an existing value and returns the changed tree.
Parameters
| Name | Type | Description |
|---|---|---|
| path | string | |
| change | Data -> Data | |
| input | Data |
Returns
Data
Verification Examples
data [ "active" => true ] |> Data.update "active" (fun _ -> Data.Bool false)
// data [ "active" => false ]kind:member
Returns all exact structural differences between two values.
Parameters
| Name | Type | Description |
|---|---|---|
| expected | Data | |
| actual | Data |
Returns
DataDifference list
Verification Examples
Data.diff (data [ "name" => "Ada" ]) (data [ "name" => "Grace" ])
// one DifferentValue difference at path "name"kind:member
kind:member
Checks path-based expectations and accumulates structured mismatches.
Parameters
| Name | Type | Description |
|---|---|---|
| expectations | DataExpectation list | |
| actual | Data |
Returns
Result<unit, DataMismatch list>
Verification Examples
Data.tryMatch [ at "name" "Ada" ] (data [ "name" => "Grace" ])
// Error [ mismatch at path "name": expected "Ada", found "Grace" ]kind:member
kind:member
kind:member
kind:member
kind:member
kind:member