How to build a nested array from a plugin parameter

I am working on a plugin where some of the parameters may contain arrays with a combination of numbers and strings.


Something like this works fine:

Code:
  var audioName = (params['Audio Name'] || '["My Audio Track", 80, 100]'
    ).replace(/[\[\]]/gi,'').split(",").map(function(value) {
    return eval(value);
  });

It gives me an array with ["My Audio Track", 80, 100] which is what I want.


But I also need to cater for the possibility that some of the content could be a nested array, such as this example for a font:

Code:
[["Tahoma", "Verdana", "Calibri"], 24, true, [0, 255, 0, 200]]
["Tahoma", 24, true, 15]

The first parameter could be just a string or an array of strings.  The last could be just a number or an array of numbers.


Not really sure how to go about this one.  Any suggestions?  I'd like to keep it fairly short.
if this plugin parameter my core have a method (it's open source to everyone 🙂 ) 


if this something else I don't know :C


NK.setArray = function(plugin, param){
return plugin[param].split(',').map( function (i) {return Number(i || 0);} );
};




for nested array well it's work mostly like the same than ruby?


you can do this : 


array.Method[0];


this will get the array inside I think in JS it's possible to get a data from his name ect....but still unsure  or this actually work like this : 


aray[0][0]




I hope this help :C
Thanks for your help, but I just figured out a super-easy solution while waiting for a response.  The following will convert a string to an array, complete with nested arrays and string, number or boolean conversion as necessary:

Code:
var myFontInfo = eval(params['Font Info'] || '[["Tahoma", "Verdana", "Calibri"], 24, true, [0, 255, 0, 200]]')



I was overthinking it.  Now to go back and change all the previous ones!
Thanks for your help, but I just figured out a super-easy solution while waiting for a response.  The following will convert a string to an array, complete with nested arrays and string, number or boolean conversion as necessary:

Code:
var myFontInfo = eval(params['Font Info'] || '[["Tahoma", "Verdana", "Calibri"], 24, true, [0, 255, 0, 200]]')



I was overthinking it.  Now to go back and change all the previous ones!

Oh nice! mind if I implement this method in my own core for nested array 😀? 
go for it - it's not my method 😉

Original thread: https://forums.rpgmakerweb.com/threads/how-to-build-a-nested-array-from-a-plugin-parameter.58555/