Last active
May 27, 2020 07:59
-
-
Save peti2001/9a7633d144decfd40baaf2151433ae9c 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
// Given a bson MongoDB query | |
q := bson.M{ | |
"$match": bson.M{ | |
"skill": bson.M{ | |
"$regex": "^cookie", | |
"$options": "-i", | |
}, | |
}, | |
} | |
// The following script will convert it into JSON | |
output, err := bson.Marshal(q) | |
var decodedBson bson.M | |
bson.Unmarshal(output, &decodedBson) | |
output, err = json.Marshal(decodedBson) | |
fmt.Println("JSON", string(output)) | |
if err != nil { | |
panic(err) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment