[Solved] Parse stringified JSON

do it in two steps. package main import ( “encoding/json” “fmt” ) func main() { type AutoGenerated struct { Messages string `json:”messages”` AppCart string `json:”app_cart”` Addcartrows string `json:”addcartrows”` MinicartContent string `json:”minicart_content”` CartQty string `json:”cart_qty”` AddedProductJSON string `json:”added_product_json”` } type addedProduct struct { ID string `json:”id”` Size string `json:”size”` } type productRow struct { ProductID string … Read more

[Solved] Unmarshal JSON to minimum type

Since you cannot describe your data in a struct then your options are to: Use a json.Decoder to convert the values to your desired types as they are parsed. Parse the document into a generic interface and post-process the value types. Option #1 is the most flexible and can likely be implemented to be more … Read more

[Solved] json.Unmarshal interface pointer with later type assertion

An empty interface isn’t an actual type, it’s basically something that matches anything. As stated in the comments, a pointer to an empty interface doesn’t really make sense as a pointer already matches an empty interface since everything matches an empty interface. To make your code work, you should remove the interface wrapper around your … Read more

[Solved] Getting an array of arrays from a POST operation into a GO calculation through reqBody and json unmarshal [closed]

fmt.Println, won’t be showing “,” between each element of array if you want to print it that way you need to format and print it var datas [][]string json.Unmarshal(reqBody, &datas) fmt.Println(“this is after the unmarshalling”) array := []string{} for _, data := range datas { array = append(array, fmt.Sprintf(“[%s]”, strings.Join(data, “,”))) } output := fmt.Sprintf(“[%s]”, … Read more