I’m engaged on an app that makes use of go to parse a json file for settings. I get the error proven beneath, but it surely’s not telling me what line within the json file is inflicting the difficulty. How do I see this?
panic: json: can't unmarshal string into Go worth of sort map[string]*json.RawMessage
You may examine your Go code to see the place you’ve a area of sort map[string]*json.RawMessage
after which examine your JSON file to see if it’s a string as a substitute.
I don’t have entry to the code. I hoped there was a approach to activate extra detailed logs like in Rust
I’m not conscious of any approach to do this in Go.
May you paste your JSON into a web-based JSON parser and see what the offending line is that approach? Additionally you possibly can organize a fast check utilizing the playground and attempt to debug it that approach. For instance, modify this playground hyperlink to have your precise JSON:
func fundamental() {
// Substitute this together with your JSON
byt := []byte(`{ "value1": "check", "value2": }`)
var dat map[string]*json.RawMessage
if err := json.Unmarshal(byt, &dat); err != nil {
panic(err)
}
fmt.Println(dat)
}
The output from that’s no less than extra descriptive than what your executable is supplying you with:
panic: invalid character '}' on the lookout for starting of worth
goroutine 1 [running]:
fundamental.fundamental()
/tmp/sandbox266866198/prog.go:13 +0xe7
Program exited.
You may additionally attempt the process outlined right here together with that go playground hyperlink to get extra information:
Although as soon as once more, a web-based JSON parser ought to work positive to provide you an in depth error message.