JavaScript Change JSON output for autocomplete

I need to chagen my JSON output which is:

[ { masterCardNo: 90363.01 }, { masterCardNo: 90363.02 }, { masterCardNo: 90363004 }, { masterCardNo: 90363004 }, { masterCardNo: 90363004 }, { masterCardNo: 90363004 }, { masterCardNo: 90363004 }, { masterCardNo: 90363004 }, { masterCardNo: 90363004 }, { masterCardNo: 2906.01 } ]

To Something like this:

[ "90363004", "90363001", "90363003"]

I have my output in a variable named "value"...

Thanks for any help..

Answer:1
var json = '[numbers { masterCardNo: 90363.01 }, { masterCardNo: 90363.02 }, { masterCardNo: 90363004 }, { masterCardNo: 90363004 }, { masterCardNo: 90363004 }, { masterCardNo: 90363004 }, { masterCardNo: 90363004 }, { masterCardNo: 90363004 }, { masterCardNo: 90363004 }, { masterCardNo: 2906.01 } ]';

var json_parsed = $.parseJSON(json);
var no = "[";
for (var i = 0; i < json_parsed.numbers.length; i++){

 no += json_parsed.numbers[i].masterCardNo+",";
}
no+="]";

try this

u can also edit as u want for some changes

Answer:2

I'm trying to achieve the below result by ONLY using the "labels" class (eg. I don't want the "arrow" class/html). Is this possible with pseudo elements only? Like ".labels:tesing{}" etc. .labels{ ...

I'm trying to achieve the below result by ONLY using the "labels" class (eg. I don't want the "arrow" class/html). Is this possible with pseudo elements only? Like ".labels:tesing{}" etc. .labels{ ...

The problem is the same as in Close all HTML unclosed IMG tags, but the provided regexp (<img[^>]+)(?<!/)> requires lookbehind support - which nodejs does not have. How can I achieve the ...

The problem is the same as in Close all HTML unclosed IMG tags, but the provided regexp (<img[^>]+)(?<!/)> requires lookbehind support - which nodejs does not have. How can I achieve the ...

I have a 'beginner' question. Why does this error out? I call the function in the code, but the function is defined further down. AngularJS version: var myApp = angular.module('myApp',[]); function ...

I have a 'beginner' question. Why does this error out? I call the function in the code, but the function is defined further down. AngularJS version: var myApp = angular.module('myApp',[]); function ...

Trying to get the tree layout in D3 to render the child nodes with children closer together. Here is the code: var margin = { top: 20, right: 120, bottom: 20, ...

Trying to get the tree layout in D3 to render the child nodes with children closer together. Here is the code: var margin = { top: 20, right: 120, bottom: 20, ...