Comments (18)
@saxsir yep, looks like json.Number
will cover both cases:
https://play.golang.org/p/75NwTQT-MG
from slack.
Slack discussion about ts
field: slackhq/slack-api-docs#7 (comment)
from slack.
I'm having same problem. (getting json: cannot unmarshal number into Go value of type string
)
How is use json.Number
instead of string
?
https://golang.org/pkg/encoding/json/#Number
Type json.Number
is an alias for string
.
http://stackoverflow.com/questions/24480835/go-decoding-json-int-into-string
from slack.
@saxsir his solution fixes it for me too
from slack.
@andrewarrow I was seeing a similar error with one of our slack servers.
I found the bit it was unable to unmarshal.
https://github.com/nlopes/slack/blob/master/attachments.go#L75
Looking at the call to our slack server
https://slack.com/api/rtm.start
token=xxxxxxxxxxxxxx
The json output for the this is datatype string and NOT int64.
I have also noticed with another one of our slack servers, where we do not have this problem, that it does not return "Attachments".
I can see now this is being discussed in issue #90
from slack.
@kodieGlosser i'm not seeing this error any more, but I think I muted the group in question causing my problem. In my project I cache each room to disk, so running touch cache/roomname/mute
the very presency of that mute file is the binary on/off value for muting. That's not really revelent to this discussion but I think it's cool. I love muting channels by just touching a file from the command line.
from slack.
Seems like I'm hitting this as well, works fine for some messages but not all. Changing the type to string worked for my scripts
from slack.
I'm having this problem as well. It was indeed introduced in https://github.com/nlopes/slack/pull/81 and the Slack API specifies TS as an Integer, however the json presents the value as a String.
I've created a fix for this issue in https://github.com/nlopes/slack/pull/96
from slack.
I have the same issue as well, just for some of messages, not for all of them.
from slack.
#96 is not a fix for it. Ts
should have string
type, not int64. In my case "ts":"1473362325.000027"
- it doesn't look like int :-)
from slack.
u don't want string you want float64
from slack.
then int64(ts) to go from 1473362325.000027, to 1473362325
from slack.
IIRC Slack's docs say it's a string and should not be stored as a float. I can't find the link at the moment. The timestamp is also a message ID and a change in precision would render it incorrect. This is why they send it as a string.
from slack.
alright let's store it as a string but have two functions to get either part of the number. The string before the dot and the string after. And then might as well have two more functions for getting both those fields as ints or as parsed Time thingys not really objects cuz golang doesn't have objects.
from slack.
Ah, I didn't know that the ts
could be that precise. Yeah, sounds like the field should be treated as a string in the model.
from slack.
Hey,
i'm also having this problem. Tried a8ceb9d (latest commit at the time) which seems to address these issue but i'm also getting this error
reconnection 4 failed: post: json: invalid use of ,string struct tag, trying to unmarshal unquoted value into int64
from slack.
Hi everyone,
Unfortunately, Slack still can send a number instead of a string in the message.attachments.ts
field. So after fetching #99, I'm getting json: cannot unmarshal number into Go value of type string
instead of the initial json: cannot unmarshal string into Go value of type int64 #92
.
from slack.
plz close this issue, thx.
from slack.
Related Issues (20)
- Webhook Sending Functions Seem to Use the Regular JSON Encoder Which Escapes HTML Characters Unnecessarily HOT 1
- Get Block data from webhook payload
- request for a release cut HOT 2
- Release 0.21.4 breaks slash commands in socket mode
- Slash Command returns "bad_error_message" HOT 7
- file_input feature support in slack-go HOT 2
- Unable to render buttons using slack.Attachment HOT 2
- Receiving no payload on websocket based events HOT 2
- Custom http client Resty retry function does not work
- Not possible to set initial value of RichTextInputBlockElement due to wrong type HOT 1
- bug: Missing `team_id` param HOT 1
- Why doesn't the getFile method return []body HOT 1
- Unable to post messages when in deployment HOT 2
- files.upload is getting deprecated by Slack HOT 1
- Upload Files V2: Ability to upload multiple files in one message HOT 1
- UploadFileV2 uploads incorrectly when using text `Content` parameter
- conversations.history unmarshall bug HOT 1
- AddRemoteFile fails because of token in querystring HOT 4
- Slack Functions HOT 2
- Events API Reconciliation HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from slack.