Created
November 7, 2018 10:36
-
-
Save Jawshua/a221a3293215c1b9631f379a17542a6a 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 ( | |
"encoding/json" | |
"fmt" | |
"github.com/tidwall/sjson" | |
) | |
func main() { | |
str := `C:\Windows\System32` | |
goMarshal := &map[string]string{ | |
"path": str, | |
} | |
// Generate with standard lib | |
data, _ := json.Marshal(goMarshal) | |
fmt.Println("Go: ", string(data)) | |
// Generate with sjson | |
strData, _ := sjson.Set("{}", "path", str) | |
fmt.Println("sjson:", strData) | |
// Attempt to unmarshal sjson data | |
var dummy interface{} | |
fmt.Println(json.Unmarshal([]byte(strData), &dummy)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment