You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
i have an implementation of jsonparser for marshaling/appending data to a json structure from a struct, but
anytime i use Set() it return a data type that is not json, but looks like a javascript object.
heres my code:
package main
import (
"github.com/buger/jsonparser"
"fmt"
)
type Layout struct {
One string `json:"one"`
}
//INCOMPLETE!!
func (l Layout) LayoutSerializer() []byte {
var ref []byte
ref = []byte(`{"one": "",`)
store,_ := jsonparser.Set(ref, []byte(l.One), "one")
return store
}
func main() {
d := Layout{One:"hello wrld",}
collect := d.LayoutSerializer()
fmt.Println(string(collect))
}
//outputs:
/*{"one": hello wrld,}*/
//instead of:
/* {"one":" hello wrld",} */
what is wrong here cause i cant parse this output as its not recognized as json data!!.
The text was updated successfully, but these errors were encountered:
i have an implementation of jsonparser for marshaling/appending data to a json structure from a struct, but
anytime i use Set() it return a data type that is not json, but looks like a javascript object.
heres my code:
what is wrong here cause i cant parse this output as its not recognized as json data!!.
The text was updated successfully, but these errors were encountered: