开发者

How to get array from JSON format in Javascript?

开发者 https://www.devze.com 2023-02-02 16:08 出处:网络
I have something like this... [\"a\",\"b\",\"c\"] I got it from PHP 开发者_如何学Carray using json_decode(). I\'m very weak in JavaScript, but I need to get array in Javascript, so I can use it wit

I have something like this...

["a","b","c"]

I got it from PHP 开发者_如何学Carray using json_decode(). I'm very weak in JavaScript, but I need to get array in Javascript, so I can use it with jQuery UI -> Autocomplete like this...

source: [ 'a', 'b', 'c' ]

Is it possible to do with only Javascript or you need to have some Javascript library to use JSON?


but I need to get array in Javascript, so I can use it with jQuery UI -> Autocomplete

Check out jQuery.parseJSON function.


Hey, You can do it only with javascript:

var arrayToUse = ["a","b","c"];

JSON stands for Javascript Object Notation and it is a standard notation for javascript objects. You do not need any special library to use it. Example,

If you want to create an object in javascript you would do something like:

var person = {
 name : 'somename',
source : arrayToUse
};

This is a javascript object in JSON notation

0

精彩评论

暂无评论...
验证码 换一张
取 消