0

I have a json response coming in from a php file, the json response looks as below results:

[
    {
        "header": "Client ID",
        "dataindex": "clientID"
    },
    {
        "header": "Client Name",
        "dataindex": "clientName"
    },
    {
        "header": "Progress Bar",
        "dataindex": "progressBar"
    }
]

Now I want to copy this data into an array in the following way var allColumns = [];

//loop through the json response
var singleColumn = [];
singleColumn['header'] = Client ID from the json response whose key is header
singleColumn[dataindex'] = clientID from the json response whose key is header.

Please note: I need to do this is extjs3.

1 Answer 1

1

If I am getting you correctly you are getting the JSON as a string from an ajax call to your PHP handler in a string format and you want to cast it into a Javascript array of coloumn objects.

you can do it like this:

var allColumns = Ext.decode(YOUR PHP JSON FORMATTED RESULT);

this will allow you to iterate over the result set as an in memory javascript array of objects like this:

for(var i=0 ; i < allColumns.length; i++){
    allColumns[i].header ...
    allColumns[i].dataindex ...
}

I hope I got you right...

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.