Skip to content

Set() doesnt return a normal json data #270

Description

@improvisor40

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!!.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions