0

I am getting data in jquery as below , I want to convert to one dimensional string Array

[
    {"2065559857":"2065559482"},
    {"2065559857":"2065553412"},
    {"2065559857":"2065558122"},
    {"2065559857":"7155354848"},
    {"2065559857":"7155577723"},
    {"2065559857":"7153555598"},
    {"2065559857":"2065551189"},
    {"2065559857":"7155544434"},
    {"2065559857":"7296363080"},
    {"2065559857":"7890128703"},
    {"2065559857":"8483894326"},
    {"2065559857":"9077659950"},
    {"2065559857":"9671425573"}
]

convert into

["2065559482","2065559857","2065553412",.....]
1

2 Answers 2

1

You can use the map method to turn each object into an array containing the key and value, and then use the same method to concatenate all the arrays:

a = $.map(a, function(o){ return $.map(o, function(x, i){ return [x, i]; }); });

Demo: http://jsfiddle.net/Guffa/XV7yz/

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

Comments

0

What about...

var jsonString = [{"2065559857":"2065559482"},{"2065559857":"2065553412"},{"2065559857":"2065558122"}];    
var myArray = [];

for(var i in jsonString){
    myArray.push([i,jsonString[i]]);
    }

Or jQuery:

var jsonString = [{"2065559857":"2065559482"},{"2065559857":"2065553412"},{"2065559857":"2065558122"}];   
var myArray = [];

$.each(jsonString, function(key,value){
    myArray.push(value);
    });​

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.