Skip to content

Commit 16a58f0

Browse files
committed
Document collections
1 parent b1504f4 commit 16a58f0

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

README.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,52 @@ type MyHub() =
102102

103103
## Format
104104

105+
### Lists
106+
107+
F# lists are serialized as JSON arrays.
108+
109+
```fsharp
110+
JsonSerializer.Serialize [1; 2; 3]
111+
// --> [1,2,3]
112+
```
113+
114+
### Sets
115+
116+
F# sets are serialized as JSON arrays.
117+
118+
```fsharp
119+
JsonSerializer.Serialize (Set [1; 2; 3])
120+
// --> [1,2,3]
121+
```
122+
123+
### Maps
124+
125+
F# string-keyed maps are serialized as JSON objects.
126+
127+
```fsharp
128+
JsonSerializer.Serialize (Map [("a", 1); ("b", 2); ("c", 3)])
129+
// --> {"a":1,"b":2,"c":3}
130+
```
131+
132+
Maps with other types as keys are serialized as JSON arrays, where each item is a `[key,value]` array.
133+
134+
```fsharp
135+
JsonSerializer.Serialize (Map [(1, "a"); (2, "b"); (3, "c")])
136+
// --> [[1,"a"],[2,"b"],[3,"c"]]
137+
```
138+
139+
### Tuples
140+
141+
Tuples and struct tuples are serialized as JSON arrays.
142+
143+
```fsharp
144+
JsonSerializer.Serialize ((1, "abc"))
145+
// --> [1,"abc"]
146+
147+
JsonSerializer.Serialize (struct (1, "abc"))
148+
// --> [1,"abc"]
149+
```
150+
105151
### Records and anonymous records
106152

107153
Records and anonymous records are serialized as JSON objects.

0 commit comments

Comments
 (0)