- 
    Type:Bug 
- 
    Resolution: Fixed
- 
    Priority:Major - P3 
- 
    Affects Version/s: None
- 
    Component/s: JSON & ExtJSON
- 
    None
- 
        (copied to CRM)
- 
        None
- 
        None
- 
        None
- 
        None
- 
        None
- 
        None
- 
        None
The extJSONValueWriter.WriteDocumenElement() method should escape keys when writing. The BI Connector team encountered an issue where a key with these characters "\usb#" could not be unmarshalled since that is not a valid unicode sequence. A simpler example is:
func main() {
	key := "\""
	doc := bson.D{{Key: key, Value: 1}}
	b, err := bson.MarshalExtJSON(&doc, false, false)
	if err != nil {
		fmt.Printf("marshal error: %v\n", err)
		return
	}
	fmt.Printf("doc: %s\n", string(b))
	err = bson.UnmarshalExtJSON(b, false, &doc)
	if err != nil {
		fmt.Printf("unmarshal error: %v\n", err)
	}
}
This outputs:
doc: {""":1}
unmarshal error: invalid JSON input: missing colon after key ""
I believe this is the only line that requires a change; the key should be escaped before writing.
- causes
- 
                    TOOLS-2453 Index keys not escaped correctly -         
- Closed
 
-