0

I am parsing JSON data and retrieving 3 values in each node,

$.each($.parseJSON(data), function (key, val) {
    Var X = val.date;
    Var y = val.type;
    Var z = val.text;
});

Example JSON data

val.date= '2011/02/09', val.type=3, val.text = 'Some text'

I wanna store these values in a array as in

var arrA = new Array();
arrA[0] = new Array(X,Y,Z);
arrA[1] = new Array(X,Y,Z); etc

WHere X,Y,Z changesfor every node in JSON data. At the end of which my arrA should contain the following data

['2011/02/09', 3, 'Some text'],
['2011/12/11', 3, 'something to show']
.
.
.
['2011/02/08,3,'something else']

What is the best way to do that?

Thanks, Adarsh

2
  • Can you post an example of the json data you will be working with? Commented Oct 14, 2011 at 4:02
  • Hi, I have out the sample JSON data in my question now Commented Oct 14, 2011 at 4:05

1 Answer 1

3
var arrA = new Array();

$.each($.parseJSON(data), function (key, val) {
    arrA.push([val.date, val.type, val.text]);
}
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.