views:

132

answers:

2

Possible Duplicate:
How to count JavaScript array objects?

If it's not a JavaScript array, so how to convert it into JSON array?

var member = {
    "mother": {
        "name" : "Mary",
        "age" : "48"
    },
    "father": {
        "name" : "Bill",
        "age" : "50",
        "friend": {
          "co-worker" : "Jake"
        }
    },
    "brother": {
        "name" : "Alex",
        "age" : "28"
    }
}
+1  A: 

There's a plugin for jQuery.

codeholic
+1  A: 

Javascript object and array literals are near-as-much identical to their JSON counterparts - JSON is just a bit more strict. Where this

{prop:"value"}

Is valid javascript, JSON requires double-quotes around property names, like so

{"prop":"value"}

So, with that in mind, what you have posted above actually is JSON (less the var member = bit, since JSON just a data format).

There is no magic "convert to array" function that will help you. If you want this data as an array, that's possible, but the exact structure of that resulting array will be specific to the needs of your application - that's not something we can guess.

Do you have an idea of what you want the resulting array to look like?

Peter Bailey