Started writing documentation and adding examples
This commit is contained in:
parent
7adb09d4db
commit
405bf812ee
5 changed files with 40 additions and 0 deletions
14
json_test.go
14
json_test.go
|
|
@ -43,3 +43,17 @@ func TestToJSON(t *testing.T) {
|
|||
})
|
||||
})
|
||||
}
|
||||
|
||||
func ExampleToJSON() {
|
||||
fruits := []string{"apple", "banana", "pineapple"}
|
||||
script.Slice(fruits).Filter(scriptx.ToJSON(func(fruit string) any {
|
||||
return map[string]any{
|
||||
"fruit": fruit,
|
||||
"length": len(fruit),
|
||||
}
|
||||
})).Stdout()
|
||||
// Output:
|
||||
// {"fruit":"apple","length":5}
|
||||
// {"fruit":"banana","length":6}
|
||||
// {"fruit":"pineapple","length":9}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue