0

I have 5 categories, each category has 3 items.

I have the array:

var myArray = ["Item1", "Item2", "Item3"];

What is the easiest way to create a Json from it without hardcoding it ?

The array in production can have thousands of items.

Mythul
  • 1,767
  • 6
  • 33
  • 53

1 Answers1

1

Use pure javascript:

JSON.stringify(myArray);

You can use json.js for compatibility with <=IE7

nicosantangelo
  • 12,546
  • 3
  • 30
  • 45