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,807
  • 7
  • 34
  • 53

1 Answers1

1

Use pure javascript:

JSON.stringify(myArray);

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

nicosantangelo
  • 13,216
  • 3
  • 33
  • 47