Created
March 18, 2025 13:18
-
-
Save NateDogg-MM/1ca86db0682e6f3b7071c743ad6f10f4 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 ( | |
"fmt" | |
"github.com/goccy/go-json" | |
) | |
type botRet struct { | |
Id *string `json:"id"` | |
Name string `json:"name"` | |
} | |
func main() { | |
var ret struct { | |
Bot *botRet `json:"bot"` | |
} | |
err := json.Unmarshal([]byte(`{"bot":{"id":"bc3c3c70-da46-4844-8712-c2ecc54bee3a","name":"Indiana Jon"}}`), &ret) | |
if err != nil { | |
panic(err) | |
} | |
jstr, err := json.Marshal(ret) | |
fmt.Println("Done", err, string(jstr)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment