Giter Club home page Giter Club logo

Comments (18)

postromantic avatar postromantic commented on August 24, 2024 4

@saxsir yep, looks like json.Number will cover both cases:
https://play.golang.org/p/75NwTQT-MG

from slack.

postromantic avatar postromantic commented on August 24, 2024 1

Slack discussion about ts field: slackhq/slack-api-docs#7 (comment)

from slack.

saxsir avatar saxsir commented on August 24, 2024 1

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.

jpbruinsslot avatar jpbruinsslot commented on August 24, 2024 1

@saxsir his solution fixes it for me too

from slack.

kodieGlosser avatar kodieGlosser commented on August 24, 2024

@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.

andrewarrow avatar andrewarrow commented on August 24, 2024

@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.

stevenpoitras avatar stevenpoitras commented on August 24, 2024

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.

aspic avatar aspic commented on August 24, 2024

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.

kulak-at avatar kulak-at commented on August 24, 2024

I have the same issue as well, just for some of messages, not for all of them.

from slack.

postromantic avatar postromantic commented on August 24, 2024

#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.

andrewarrow avatar andrewarrow commented on August 24, 2024

u don't want string you want float64

from slack.

andrewarrow avatar andrewarrow commented on August 24, 2024

then int64(ts) to go from 1473362325.000027, to 1473362325

from slack.

tobert avatar tobert commented on August 24, 2024

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.

andrewarrow avatar andrewarrow commented on August 24, 2024

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.

aspic avatar aspic commented on August 24, 2024

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.

tonka3000 avatar tonka3000 commented on August 24, 2024

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.

adyatlov avatar adyatlov commented on August 24, 2024

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.

saxsir avatar saxsir commented on August 24, 2024

plz close this issue, thx.

from slack.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.