Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9258627
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T12:27:20+00:00 2026-06-18T12:27:20+00:00

I have a json response which has a function call inside. It looks like

  • 0

I have a json response which has a function call inside. It looks like string after parsing

"foo({a: 5}, 5, 100)"

How can I extract the first argument of the function call (in this case it’s {a: 5})?.

update

Here is the code from the server side

var request = require('request')
  , cheerio = require('cheerio');

var url = 'http://www.google.com/dictionary/json?callback=dict_api.callbacks.id100&q=test&sl=en&tl=en';

request({url: url, 'json': true}, function(error, resp, body){
  console.log(typeof JSON.parse(body)); // => string
});
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T12:27:21+00:00Added an answer on June 18, 2026 at 12:27 pm

    The Google Dictionary API (undocumented) uses JSONP, which is not really JSON, so you can’t use it in your node.js (as you noted in your comment) in the way that you’d like. You’ll have to eval() the response.

    Notice how the query params has callback=dict_api.callbacks.id100? That means that the returned data is going to be returned like this: dict_api.callbacks.id100(/* json here */, 200, null)

    So, you have two options: 1: create a function in your code:

    var dict_api = { callbacks: { id100: function (json_data) {
        console.log(json_data);
    }};
    
    request({url: url, 'json': true}, function(error, resp, body){
        // this is actually really unsafe. I don't recommend it, but it'll get the job done
        eval(body);
    });
    

    Alternatively, you can pull off the start (dict_api.callbacks.id100() and end (,200,null) [assuming this will always be the same]), and then JSON.parse() the resulting string.

    request({url: url, 'json': true}, function(error, resp, body){
        // this is actually really unsafe. I don't recommend it, but it'll get the job done
        var json_string = body.replace('dict_api.callbacks.id100(', '').replace(',200,null)', '');
        console.log(JSON.parse(json_string));
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a php function which returns JSON in response to a ajax request
We have a JSON response which can contain null values (e.g. { myValue: null
I have a url which have a response in Json lon=-0.1275&pg=0 I parsed the
I have a json response like: { total: 2, success: true, rows: [ {a1_id:7847TK10,
I have this JSON response string: {d:{\ID_usuario\:\000130\,\Nombre\:null,\Vipxlo\:0,\Provmun\:null,\Descuentos\:null,\Listaviplocal\:null}}` With this code: - (void)connectionDidFinishLoading:(NSURLConnection *)connection {
I have a RESTful WCF service (.NET 3.5), which has a function that is
So I have the following code which i basically just a JSON string I
I have a json form field which has a check box as coded :
I have a JSON response that is formatted from my C# WebMethod using the
If i have this json response {error:repeated} Why the alert is not showed? It

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.