Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

encoding/json: Unmarshal ignore the exact case and match the case-intensitive one and throw an error #15232

Closed
iCoolchar opened this issue Apr 11, 2016 · 1 comment

Comments

Projects
None yet
3 participants
@iCoolchar
Copy link

commented Apr 11, 2016

Please answer these questions before submitting your issue. Thanks!

  1. What version of Go are you using (go version)?

    go version go1.4.2 darwin/amd64

  2. What operating system and processor architecture are you using (go env)?

    GOARCH="amd64"
    GOBIN="/usr/local/go/bin"
    GOCHAR="6"
    GOEXE=""
    GOHOSTARCH="amd64"
    GOHOSTOS="darwin"
    GOOS="darwin"
    GOPATH="/Users/myName/Projects/test/go"
    GORACE=""
    GOROOT="/usr/local/go"
    GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
    CC="clang"
    GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fno-common"
    CXX="clang++"
    CGO_ENABLED="1"

  3. What did you do?
    I want to get the property of an object from neo4j and there is two properties with the same name but one is upper case and the other is lower case. And their type is different. The code is like

package main
import (
"myProject/config"
"myProject/log"
"myProject/service/neo4j"
)
type MetaData struct {
ID int64 json:"ID"
Name string json:"name"
}
func main() {
config.Init()
compID := int64(3)
preData := MetaData{}
err := neo4j.REST.GetNodeProperty(compID, &preData)
log.Info.Println("result is", preData.Name)
log.Info.Println("error is", err)
}

The Get function called
func Unmarshal(data []byte, v interface{}) error
in https://golang.org/src/encoding/json/decode.go
neo4j data is like
{ id: 3, Name: [1,2,3], name: "test" }

which Name is an array and name is a string

  1. What did you expect to see?
    it should get the lower case name property and ignore the upper case Name property
  2. What did you see instead?
    error is json: cannot unmarshal array into Go value of type string
@minux

This comment has been minimized.

Copy link
Member

commented Apr 11, 2016

@minux minux changed the title Unmarshal ignore the exact case and match the case-intensitive one and throw an error encoding/json: Unmarshal ignore the exact case and match the case-intensitive one and throw an error Apr 11, 2016

@minux minux closed this Apr 11, 2016

@golang golang locked and limited conversation to collaborators Apr 11, 2017

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.