Skip to content

Commit 5f6a2d9

Browse files
committed
Update zero values section in README
1 parent 3d8ee21 commit 5f6a2d9

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,29 @@ While encouraged, it is not necessary to define a type (e.g. a `struct`) in orde
131131

132132
By default, and without custom marshaling, zero values (also known as empty/default values) are encoded as the empty string. To disable this behavior, meaning to keep zero values in their literal form (e.g. `0` for integral types), `Encoder` offers a `KeepZeros` setter method, which will do just that when set to `true`.
133133

134+
For instance, given...
135+
136+
```go
137+
foo := map[string]interface{}{"b": false, "i": 0}
138+
```
139+
140+
...the following...
141+
142+
```go
143+
form.EncodeToString(foo) // i.e. keepZeros == false
144+
```
145+
146+
...will result in `"b=&i="`, whereas...
147+
148+
```go
149+
keepZeros := true
150+
delimiter := '.'
151+
escape := '\\'
152+
form.EncodeToStringWith(foo, delimiter, escape, keepZeros)
153+
```
154+
155+
...will result in `"b=false&i=0"`.
156+
134157
### Unsupported Values
135158

136159
Values of the following kinds aren't supported and, if present, must be ignored.

0 commit comments

Comments
 (0)