Skip to content
This repository has been archived by the owner on Mar 15, 2019. It is now read-only.

Cannot properly parse id's returned by taobao.tmc.messages.consume (TmcMessage) #8

Closed
lukewarm opened this issue Oct 5, 2013 · 6 comments
Labels

Comments

@lukewarm
Copy link

lukewarm commented Oct 5, 2013

This is not exactly an issue of the package. But as is, it cannot parse ids from TOP's message service. The ids are integers too large for JavaScript's int. As a result, the built-in JSON.parse rounds down the numbers. E.g.

7091800003790954036 -> 7091800003790954000

I'm using a custom parser as a work-around for this api only, but don't know the performance implications.

@fengmk2
Copy link
Member

fengmk2 commented Oct 5, 2013

I think the best way is tell TOP this issue and let them return a new property is_str like weibo API does.

@lukewarm
Copy link
Author

lukewarm commented Oct 5, 2013

Makes sense to me. Will open a ticket there. Don't know if will change though :-). Thanks for the great package.

@fengmk2
Copy link
Member

fengmk2 commented Oct 5, 2013

Can you upload a json result for this issue, I want to wrap this issue
before TOP accept the solution.
在 2013-10-5 AM9:58,"lukewarm" notifications@github.com写道:

Makes sense to me. Will open a ticket there. Don't know if will change
though :-). Thanks for the great package.


Reply to this email directly or view it on GitHubhttps://github.com//issues/8#issuecomment-25740078
.

@lukewarm
Copy link
Author

lukewarm commented Oct 5, 2013

Not sure if I understand what's needed. Let me know if this is not helpful. Sorry, I'm new to to JavaScript.

This is the parsed results. The id property is the integer that's too long and rounded down.

{
  tmc_messages_consume_response: {
    messages: {
      tmc_message: [
        {user_id: 123456789,
         user_nick: 'usernick',
         content: '{"nick":"usernick","increment":1,"num":502,"changed_fields":"num","num_iid":15380658823}',
         id: 7104300007405429000,
         pub_time: '2013-10-05 10:55:58',
         pub_app_key: '12499723',
         topic: 'taobao_item_ItemStockChanged' }
        ]
    }
  }
}

JSON string

{"tmc_messages_consume_response":{"messages":{"tmc_message":[{"user_id":123456789,"user_nick":"usernick","content":"{\\"nick\\":\\"usernick\\",\\"increment\\":1,\\"num\\":502,\\"changed_fields\\":\\"num\\",\\"num_iid\\":15380658823}","id":7104300007405429232,"pub_time":"2013-10-05 10:55:58","pub_app_key":"12499723","topic":"taobao_item_ItemStockChanged"}]}}}

@ghost ghost assigned fengmk2 Oct 7, 2013
@fengmk2 fengmk2 closed this as completed in 1eb0119 Oct 7, 2013
@fengmk2
Copy link
Member

fengmk2 commented Oct 7, 2013

@lukewarm I fix this on top@0.2.0 , change Long Number id property to String id.

@lukewarm
Copy link
Author

lukewarm commented Oct 7, 2013

Awesome man! Will post any updates here when TOP responds to the request of a string id.

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

No branches or pull requests

2 participants