new files
This commit is contained in:
parent
3af7344581
commit
86c034bb8b
1364 changed files with 21352 additions and 0 deletions
25
Task/JSON/Go/json-1.go
Normal file
25
Task/JSON/Go/json-1.go
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
package main
|
||||
|
||||
import "encoding/json"
|
||||
import "fmt"
|
||||
|
||||
func main() {
|
||||
var data interface{}
|
||||
err := json.Unmarshal([]byte(`{"foo":1, "bar":[10, "apples"]}`), &data)
|
||||
if err == nil {
|
||||
fmt.Println(data)
|
||||
} else {
|
||||
fmt.Println(err)
|
||||
}
|
||||
|
||||
sample := map[string]interface{}{
|
||||
"blue": []interface{}{1, 2},
|
||||
"ocean": "water",
|
||||
}
|
||||
json_string, err := json.Marshal(sample)
|
||||
if err == nil {
|
||||
fmt.Println(string(json_string))
|
||||
} else {
|
||||
fmt.Println(err)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue