How to get an array from JSON format in Javascript?

I have something like this ...

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

I got it from a PHP array using json_decode (). I am very weak in JavaScript, but I need to get an array in Javascript, so I can use it with jQuery UI -> Autocomplete, like this ...

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

Can I use only Javascript or do you need a Javascript library to use JSON?

+4
source share
2 answers

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

Open jQuery.parseJSON .

+5
source

Hey, you can only do this with javascript:

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

JSON stands for Javascript Object Notation, and this is the standard notation for javascript objects. You do not need a 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
source

Source: https://habr.com/ru/post/1333976/


All Articles