Created
December 9, 2022 06:51
-
-
Save abtswath/fd1fcf4cbde3ba553050cb0f8c6daa97 to your computer and use it in GitHub Desktop.
JSON to Map
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"encoding/json" | |
"fmt" | |
"log" | |
) | |
func main() { | |
s := ` | |
{ | |
"code": 200, | |
"data": { | |
"token": "asdfdsafdxzcvsadf" | |
} | |
} | |
` | |
var m map[string]interface{} | |
err := json.Unmarshal([]byte(s), &m) | |
if err != nil { | |
log.Fatalln(err) | |
} | |
fmt.Println(m) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment