-
Notifications
You must be signed in to change notification settings - Fork 282
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
Help: Unable to unmarshal server reply containing a map into map[string]interface{}
#63
Comments
I think you're not doing anything wrong, the problem here is that the Is |
Thanks for your answer! I guess my option is not to use your library in this case then and instead use simple json. |
From what I saw, the json reply contains a map both when the reply is expected to be a struct and a map (as in my case). Your library only can interpret json maps as structs with tags that correspond to the json map keys. The unmarshalling fails as in my example, |
I stumbled across the same issue. The thing is the library resolves the query, gets back the json response, iterates through it and while doing that it tries to assign the json values it finds to the appropriate struct fields. This is working fine as long as you are able to define exactly what will be in the response. But in our case one of our json response fields contains a map of unknown values (map[string]interface{}). On client side reaching that point in the json response lets the library fail with an error like |
* Fix typo in Events section of the readme file
Good time of the day!
I'm having an issue with unmarshalling a server reply payload into Golang's
map[string]interface{}
.The server uses gqlgen and the inbuilt scalar Map! in both input and output.
The mutation input and output in the server schema:
The structs used on the client side:
The mutation executes correctly and returns json of the form (got this from a Wireshark capture of the server reply):
Error on the client side:
struct field for "Date" doesn't exist in any of 1 places to unmarshal
I need
OutputMap
to be of typemap[string]interface{}
and notstruct
as the keys and the number of keys may vary. Am I doing something wrong or is it so that the library can't work with Golang maps?I've tried executing the mutation using a plain http client with json and the mutation and unmarshalling of the payload work without a problem.
Thank you for your help,
A
The text was updated successfully, but these errors were encountered: