2

I didn't find the keyword for google...

My Problem is

let's have a json array

{
  "a":"b",
  "c" : "d",
  "api" : 
  {
    "name":"listOfNetwork",
    "param" :['xyz','xyz1']
  } 
}

Now i have a javascript method

function listOfNetwork(param1, param2) //name-of-api, params
{
     // do something.
}

how to invoke this function by retrieving the name and parameters from JSON.

Please help

1
  • Assuming that the JSON array is called myJSON, you could get the values from the array by calling myJSON.api.name, myJSON.api.param[0], etc. Hope that helps. Commented Mar 7, 2013 at 1:40

1 Answer 1

6
window[json.api.name].apply(this, json.api.param)

Thats all.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.