Skip to content

Commit

Permalink
fix(go): parsing tag
Browse files Browse the repository at this point in the history
  • Loading branch information
rot1024 committed Dec 22, 2023
1 parent 76280be commit a6b9b08
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions go/value.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,27 @@ func TagFrom(j any) *Tag {
return nil
}

m, ok := j.(map[string]any)
if !ok {
if m2, ok := j.(map[any]any); ok {
m = make(map[string]any, len(m2))
for k, v := range m2 {
if k, ok := k.(string); ok {
m[k] = v
}
}
}
return nil
}

t := Tag{}
if id, ok := j.(map[string]any)["id"].(string); ok {
if id, ok := m["id"].(string); ok {
t.ID = id
}
if name, ok := j.(map[string]any)["name"].(string); ok {
if name, ok := m["name"].(string); ok {
t.Name = name
}
if color, ok := j.(map[string]any)["color"].(string); ok {
if color, ok := m["color"].(string); ok {
t.Color = color
}

Expand Down

0 comments on commit a6b9b08

Please sign in to comment.