2

I'm using Node/Express to make API requests to the unofficial Vine API.

The data that the GET https://api.vineapp.com/users/search/ route returns changes on parsing.

My code is the following:

request({ url: 'https://api.vineapp.com/users/search/' + username }, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(typeof body,'UNPARSED BODY:', body);

  body = JSON.parse(body);

  console.log(typeof body,'PARSED BODY:', JSON.stringify(body, null, 2));

  cb(null, body)
});

This is what is returns: enter image description here The data.records.userId changes on parsing.

Why does this happen? Am I missing something here? Why would they do that?

Tomalak
  • 332,285
  • 67
  • 532
  • 628
sznrbrt
  • 993
  • 2
  • 11
  • 32
  • What is the userId before you parse the response? Also are you using any custom validations or custom types (like mongodb's ObjectId field type) ? – Vasil Dininski Jun 28 '16 at 08:51

1 Answers1

6

The number is too high for the JSON parser

Info about the highest possible value in javascript:
What is JavaScript's highest integer value that a Number can go to without losing precision?

There is a solution provided here:
node.js is there any proper way to parse JSON with large numbers? (long, bigint, int64)

Community
  • 1
  • 1
Simon Hänisch
  • 4,740
  • 2
  • 30
  • 42