javascript - parse http response content string -


I am working with JavaScript in the meteor and I request an HTTP.get request for an API and a response I get res = {..., content: "access_token = 4h378fi243h085giouf245 and end = 5180430", data = zero} . As you can see, res.content is a string but it actually reflects a good JSON object {access_token: 4h378fi243h085giouf245, expired: 5180430} .

Is there a meteor or javascript package / easy solution to convert that string into that object?

(I've seen some manual string parsing solutions but it seems to be hacking, and it seems that some meteors or javascript will provide for you.)

Edit: JSON.parse Res.content is really the first attempt, but it gives me 'unexpected token', I'm guessing 'access_token'. Why would not this happen?

This is not really JSON, this is the URL criteria string.

  var results = {}; Res.content.split ("& amp;") forEach (function) {var item = part.split ("="); Results [item [0]] = decodeurIComponent (object [1]);}); Results = JSON. Pars (results);    

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -