Created
August 17, 2023 11:02
-
-
Save FabioRodrigues/aff3e7f598aa3264cd9b1d7b6dc04514 to your computer and use it in GitHub Desktop.
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 ( | |
"fmt" | |
"log" | |
"github.com/vmihailenco/msgpack" | |
) | |
func main() { | |
// Create a sample map[string]interface{} | |
personMap := map[string]interface{}{ | |
"Name": "Jane Smith", | |
"Age": 25, | |
"Address": "456 Elm St, Town", | |
} | |
// Serialize the map to MessagePack format | |
packedData, err := msgpack.Marshal(personMap) | |
if err != nil { | |
log.Fatal(err) | |
} | |
fmt.Println("Serialized data:", packedData) | |
// Deserialize the MessagePack data back to a map | |
var unpackedMap map[string]interface{} | |
err = msgpack.Unmarshal(packedData, &unpackedMap) | |
if err != nil { | |
log.Fatal(err) | |
} | |
fmt.Println("Unpacked Map:", unpackedMap) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment