Documentation
¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ToInterface ¶
ToInterface unmarshalls JSON reader to a "generic" interface
Example (Empty) ¶
package main
import (
"fmt"
"os"
"reflect"
"strings"
"github.com/VirtusLab/go-extended/pkg/json"
)
func main() {
js := ``
data, err := json.ToInterface(strings.NewReader(js))
if err != nil {
_, _ = fmt.Fprint(os.Stderr, err)
}
fmt.Println(data)
fmt.Println(reflect.TypeOf(data))
fmt.Println(reflect.ValueOf(data).Kind())
}
Output: map[] map[string]interface {} map
Example (Simple) ¶
package main
import (
"fmt"
"os"
"reflect"
"strings"
"github.com/VirtusLab/go-extended/pkg/json"
)
func main() {
js := `{
"welcome":{
"message":["Good Morning", "Hello World!"]
}
}`
data, err := json.ToInterface(strings.NewReader(js))
if err != nil {
_, _ = fmt.Fprint(os.Stderr, err)
}
fmt.Println(data)
fmt.Println(reflect.TypeOf(data))
fmt.Println(reflect.ValueOf(data).Kind())
}
Output: map[welcome:map[message:[Good Morning Hello World!]]] map[string]interface {} map
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.