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

fix: wrong way of Unmarshal #4397

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

wangshiben
Copy link

I faced a minor problem when I used it.
for examlpe:

type request {
	Bytes []byte `json:"bytes"`
	Name  string `json:"name"`
}

type response {}

service template {
	@handler postDataTest
	post /test (request) returns (response)

	@handler getJsonData
	get /get returns (request)
}

and get returns

&types.Request{
		Bytes: []byte("11122344wsss"),
		Name:  "test",
	}

It's ok when I visit /get api ,but when I put /get response (the json data of request) into /test error happend:

fullName: `bytes`, error: `string: `MTExMjIzNDR3c3Nz`, error: `invalid character 'M' looking for beginning of value``

and I notice that ,there use json.Marshal() to make the response but use slef custom mapping.UnmarshalJsonReader to Unmarshal json data

so I just fix it (core in mapping.processFieldNotFromString).

You can see test in TestUnmarshalJsonReaderMultiArray

…onx.Marshal but jsonx.Umarshal works wrong way
@wangshiben
Copy link
Author

@kevwan please help review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant