Quick actions

cmd+k|ctrl+k

Navigation

Languages

Unmarshalling

Snippet info

Language

Go

Visibility

public

Author

ubaidillah.hf

Created

2022-11-23T12:08:18.215395Z

Updated

2022-11-23T12:08:18.215395Z

package main

import (
    "fmt"
    "encoding/json"
)

type CobaStruct struct{
    Coba *string `json:"cobaDong"`
}

func main() {
    values := map[string]string{
		"cobaDong": "Platypus",
	}
	
	jsonValue, _ := json.Marshal(values)
    // var jsonBlob = []byte(`{"cobaDong": "Platypus"}`)
    dataRes := &CobaStruct{}
	err := json.Unmarshal(jsonValue, dataRes)
	if err != nil {
		fmt.Println("error:", err)
	}

    fmt.Printf("Cek =>%v\n", dataRes)
}
INFO