diff --git a/pkg/obiformats/json_writer.go b/pkg/obiformats/json_writer.go index 0d4193b..4d8009d 100644 --- a/pkg/obiformats/json_writer.go +++ b/pkg/obiformats/json_writer.go @@ -6,6 +6,8 @@ import ( "encoding/json" "io" "os" + "strconv" + "strings" "sync" "time" @@ -15,6 +17,14 @@ import ( log "github.com/sirupsen/logrus" ) +func _UnescapeUnicodeCharactersInJSON(_jsonRaw []byte) ([]byte, error) { + str, err := strconv.Unquote(strings.Replace(strconv.Quote(string(_jsonRaw)), `\\u`, `\u`, -1)) + if err != nil { + return nil, err + } + return []byte(str), nil +} + func JSONRecord(sequence *obiseq.BioSequence) []byte { record := make(map[string]interface{}, 4) @@ -38,6 +48,12 @@ func JSONRecord(sequence *obiseq.BioSequence) []byte { log.Panicf("conversion to JSON error on sequence id %s", sequence.Id()) } + text, error = _UnescapeUnicodeCharactersInJSON(text) + + if error != nil { + log.Panicf("conversion to JSON error on sequence id %s", sequence.Id()) + } + return text }