Skip to content

Commit 21a6575

Browse files
committed
let's convert left key to string ^^ problem #1
1 parent 6f10061 commit 21a6575

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

decode.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,27 @@
11
package main
22

3+
import (
4+
"fmt"
5+
"strconv"
6+
)
7+
38
func decode(input interface{}) interface{} {
49
switch in := input.(type) {
510
case map[interface{}]interface{}:
611
rec := map[string]interface{}{}
712
for k, v := range in {
8-
rec[k.(string)] = decode(v)
13+
14+
switch k.(type) {
15+
case bool:
16+
rec[strconv.FormatBool(k.(bool))] = decode(v)
17+
case int:
18+
rec[strconv.Itoa(k.(int))] = decode(v)
19+
case float64:
20+
rec[fmt.Sprintf("%f", k.(float64))] = decode(v)
21+
case string:
22+
rec[k.(string)] = decode(v)
23+
}
24+
925
}
1026
return rec
1127
case []interface{}:

0 commit comments

Comments
 (0)