Javascript - Json array function, Javascript json array


Json array function

function array1dToJson(a, p) 
{
var i, s = '[';
for (i = 0; i < a.length; ++i) 
{
if (typeof a[i] == 'string') 
{
s += '"' + a[i] + '"';
}
else 
{ // assume number type
s += a[i];
}
if (i < a.length - 1) 
{
s += ',';
}
}
s += ']';
if (p) 
{
return '{"' + p + '":' + s + '}';
}
return s;
}

Javascript - Javascript json array
The topic on Javascript - Json array function is posted by - Math
Hope you have enjoyed, Javascript - Json array function . Thanks for your time.

All rights reserved. © www.w3calculator.com