mirror of
https://github.com/metabarcoding/obitools4.git
synced 2025-06-29 16:20:46 +00:00
Parse correctly json header when a curly brace is included in a string.
Former-commit-id: 35225bc7db165825d4e5ef583324e54829695503
This commit is contained in:
@ -17,18 +17,24 @@ func _parse_json_header_(header string, annotations obiseq.Annotation) string {
|
||||
stop := -1
|
||||
level := 0
|
||||
lh := len(header)
|
||||
inquote := false
|
||||
|
||||
for i := 0; (i < lh) && (stop < 0); i++ {
|
||||
// fmt.Printf("[%d,%d-%d] : %d (%c) (%d,%c)\n", i, start, stop, header[i], header[i], '{', '{')
|
||||
if level == 0 && header[i] == '{' {
|
||||
if level == 0 && header[i] == '{' && !inquote {
|
||||
start = i
|
||||
}
|
||||
|
||||
if header[i] == '{' {
|
||||
// TODO: escaped double quotes are not considered
|
||||
if start > -1 && header[i] == '"' {
|
||||
inquote = !inquote
|
||||
}
|
||||
|
||||
if header[i] == '{' && !inquote {
|
||||
level++
|
||||
}
|
||||
|
||||
if header[i] == '}' {
|
||||
if header[i] == '}' && !inquote {
|
||||
level--
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user