You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi @Arman92 , I have use your awesome td-lib for some days. Today I found when I call GetInlineQueryResults methon and I got an error:
cannot unmarshal object into Go struct field InlineQueryResults.results of type tdlib.InlineQueryResult
I trace the error and found unmarshalInlineQueryResult have no used by any function of type.go and method.go. And InlineQueryResults have not implement UnmarshalJSON function.
I try to write it by hand with a simple code:
// UnmarshalJSON unmarshal to jsonfunc (inlineQueryResults*InlineQueryResults) UnmarshalJSON(b []byte) error {
varobjMapmap[string]*json.RawMessageerr:=json.Unmarshal(b, &objMap)
iferr!=nil {
returnerr
}
tempObj:=struct {
tdCommonInlineQueryIDJSONInt64`json:"inline_query_id"`// Unique identifier of the inline queryNextOffsetstring`json:"next_offset"`// The offset for the next request. If empty, there are no more resultsSwitchPmTextstring`json:"switch_pm_text"`// If non-empty, this text should be shown on the button, which opens a private chat with the bot and sends the bot a start message with the switch_pm_parameterSwitchPmParameterstring`json:"switch_pm_parameter"`// Parameter for the bot start message
}{}
err=json.Unmarshal(b, &tempObj)
iferr!=nil {
returnerr
}
inlineQueryResults.tdCommon=tempObj.tdCommoninlineQueryResults.InlineQueryID=tempObj.InlineQueryIDinlineQueryResults.NextOffset=tempObj.NextOffsetinlineQueryResults.SwitchPmText=tempObj.SwitchPmTextinlineQueryResults.SwitchPmParameter=tempObj.SwitchPmParametervarResults []InlineQueryResultvartempResults []*json.RawMessagebyteResults, err:=objMap["results"].MarshalJSON()
iferr!=nil {
returnerr
}
err=json.Unmarshal(byteResults, &tempResults)
iferr!=nil {
returnerr
}
for_, r:=rangetempResults {
fieldResult, _:=unmarshalInlineQueryResult(r)
Results=append(Results, fieldResult)
}
inlineQueryResults.Results=Resultsreturnnil
}
and the error gone. So I think the parser may have some bugs and cause some necessary code not generated. But the parser code is a bit complex and I dont know how to fix it now. Can you check it out? Thanks.
The text was updated successfully, but these errors were encountered:
Hi @Arman92 , I have use your awesome td-lib for some days. Today I found when I call GetInlineQueryResults methon and I got an error:
I trace the error and found unmarshalInlineQueryResult have no used by any function of type.go and method.go. And InlineQueryResults have not implement UnmarshalJSON function.
I try to write it by hand with a simple code:
and the error gone. So I think the parser may have some bugs and cause some necessary code not generated. But the parser code is a bit complex and I dont know how to fix it now. Can you check it out? Thanks.
The text was updated successfully, but these errors were encountered: