I would like to convert string like this
1:S 2:L 3:I 4:I 5:I 6:I 7:I 8:I 9:I 10:I 11:I 12:L 13:I 14:I 15:I 16:I
to JSON struct
type Item struct {
Id int
Status string
}
My code looks like
package main
import (
"fmt"
"encoding/json"
)
type Item struct {
Id int
Status string
}
var str = "1:I 2:I 3:I 4:I 5:I 6:I 7:I 8:I 9:I 10:I 11:I 12:L 13:I 14:I 15:I 16:I"
func main() {
fmt.Println(str)
var results []map[string]interface{}
json.Unmarshal([]byte(str), &results)
out, _ := json.Marshal(results)
println(string(out))
}
Whether such mapping is possible or I should add comma and quotation marks in the string ?
Any help will be welcome.